Skip to content

Commit 092af0c

Browse files
committed
Fix seed_hd_data.py
1 parent 0daa773 commit 092af0c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/fastapi_app/seed_hd_data.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ def convert_to_str(value):
4040
return str(value)
4141

4242

43-
async def seed_data(engine):
44-
logger.info("Checking if the packages_all table exists...")
43+
async def seed_data(engine, table_name):
44+
logger.info(f"Checking if the {table_name} table exists...")
4545
async with engine.begin() as conn:
4646
result = await conn.execute(
4747
text(
48-
"""
48+
f"""
4949
SELECT EXISTS
50-
(SELECT 1 FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'packages_all')
50+
(SELECT 1 FROM information_schema.tables WHERE table_schema = 'public' AND table_name = '{table_name}')
5151
""" # noqa
5252
)
5353
)
@@ -93,8 +93,6 @@ async def seed_data(engine):
9393
record["price_to_reserve_for_this_package"] = convert_to_float(
9494
record["price_to_reserve_for_this_package"]
9595
)
96-
if "brand_ranking_position" in record:
97-
record["brand_ranking_position"] = convert_to_int(record["brand_ranking_position"])
9896

9997
package = await session.execute(select(Package).filter(Package.url == record["url"]))
10098
if package.scalars().first():
@@ -140,7 +138,9 @@ async def main():
140138
else:
141139
engine = await create_postgres_engine_from_args(args)
142140

143-
await seed_data(engine)
141+
table_name = input("Insert table_name: ") # e.g. packages_all, packages_all_staging
142+
143+
await seed_data(engine, table_name)
144144
await engine.dispose()
145145

146146

0 commit comments

Comments
 (0)