ritvik360 commited on
Commit
a069777
·
verified ·
1 Parent(s): 1c64977

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. server/app.py +7 -1
server/app.py CHANGED
@@ -35,8 +35,14 @@ app = create_fastapi_app(
35
  async def startup_event():
36
  from db.seed import seed_database
37
 
38
- # You MUST create the connection and pass it into the function
39
  conn = sqlite3.connect('ecommerce.db')
 
 
 
 
 
 
 
40
  seed_database(conn)
41
  conn.commit()
42
  conn.close()
 
35
  async def startup_event():
36
  from db.seed import seed_database
37
 
 
38
  conn = sqlite3.connect('ecommerce.db')
39
+
40
+ # NEW FIX: Read and execute the schema DDL first!
41
+ with open('db/schema.sql', 'r') as f:
42
+ schema_sql = f.read()
43
+ conn.executescript(schema_sql)
44
+
45
+ # Now that tables exist, insert the data
46
  seed_database(conn)
47
  conn.commit()
48
  conn.close()