Loading all tables complete

This commit is contained in:
Guillem Borrell 2024-05-23 18:12:27 +02:00
parent 01ae8c9ffb
commit 1040a18545
3 changed files with 16 additions and 0 deletions

View file

@ -92,6 +92,18 @@ class DDB:
.fetchall()[0][0] .fetchall()[0][0]
.split(";") .split(";")
) )
# Load all the tables into the database
for sheet in self.sheets:
self.db.query(f"""
create table {sheet} as (
select
*
from
read_csv_auto('{path}/{sheet}.csv')
)
""")
return self return self
def load_folder_gcs(self, path: str) -> Self: def load_folder_gcs(self, path: str) -> Self:

View file

@ -19,4 +19,8 @@ def test_dump():
def test_load(): def test_load():
db = DDB().load_folder_local(TEST_OUTPUT_FOLDER) db = DDB().load_folder_local(TEST_OUTPUT_FOLDER)
results = db.query("select * from answers").fetchall()
assert db.sheets == ("answers",) assert db.sheets == ("answers",)
assert len(results) == 2