Fred808 commited on
Commit
6a002d2
·
verified ·
1 Parent(s): ee95ee0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -104,11 +104,23 @@ async def add_order_ids_column():
104
  async with engine.connect() as conn:
105
  await conn.execute(text("ALTER TABLE user_profiles ADD COLUMN order_ids TEXT DEFAULT ''"))
106
  await conn.commit()
107
-
 
 
 
 
 
108
 
109
- # Run the function to add the column
110
- asyncio.run(await add_order_ids_column())
 
 
 
111
 
 
 
 
 
112
  async def init_db():
113
  async with engine.begin() as conn:
114
  await conn.run_sync(Base.metadata.create_all)
 
104
  async with engine.connect() as conn:
105
  await conn.execute(text("ALTER TABLE user_profiles ADD COLUMN order_ids TEXT DEFAULT ''"))
106
  await conn.commit()
107
+ print("Column 'order_ids' added successfully.")
108
+
109
+ async def init_db():
110
+ async with engine.begin() as conn:
111
+ await conn.run_sync(Base.metadata.create_all)
112
+ print("Database initialized.")
113
 
114
+ # The main function serves as the entry point for our async operations.
115
+ async def main():
116
+ # Await each coroutine in order
117
+ await add_order_ids_column()
118
+ await init_db()
119
 
120
+ if __name__ == "__main__":
121
+ # asyncio.run() creates a new event loop and runs the main() coroutine inside it.
122
+ asyncio.run(main())
123
+
124
  async def init_db():
125
  async with engine.begin() as conn:
126
  await conn.run_sync(Base.metadata.create_all)