@@ -40,14 +40,14 @@ def convert_to_str(value):
40
40
return str (value )
41
41
42
42
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..." )
45
45
async with engine .begin () as conn :
46
46
result = await conn .execute (
47
47
text (
48
- """
48
+ f """
49
49
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 } ')
51
51
""" # noqa
52
52
)
53
53
)
@@ -93,8 +93,6 @@ async def seed_data(engine):
93
93
record ["price_to_reserve_for_this_package" ] = convert_to_float (
94
94
record ["price_to_reserve_for_this_package" ]
95
95
)
96
- if "brand_ranking_position" in record :
97
- record ["brand_ranking_position" ] = convert_to_int (record ["brand_ranking_position" ])
98
96
99
97
package = await session .execute (select (Package ).filter (Package .url == record ["url" ]))
100
98
if package .scalars ().first ():
@@ -140,7 +138,9 @@ async def main():
140
138
else :
141
139
engine = await create_postgres_engine_from_args (args )
142
140
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 )
144
144
await engine .dispose ()
145
145
146
146
0 commit comments