kamau1 commited on
Commit
b70050e
·
verified ·
1 Parent(s): 2203b30

Upload 10 files

Browse files
Files changed (1) hide show
  1. main.py +8 -2
main.py CHANGED
@@ -52,9 +52,15 @@ async def startup_db_client():
52
  raise Exception(error_msg)
53
 
54
  try:
55
- # Use the direct URL connection method (recommended for Hugging Face)
56
  print(f"Connecting to Turso database at: {db_url}")
57
- app.db_conn = libsql.connect(db_url, auth_token=auth_token.strip())
 
 
 
 
 
 
58
 
59
  # Test connection
60
  result = app.db_conn.execute("SELECT 1").fetchone()
 
52
  raise Exception(error_msg)
53
 
54
  try:
55
+ # Use the URL with embedded auth token
56
  print(f"Connecting to Turso database at: {db_url}")
57
+ # Format the URL to include the auth token
58
+ if "?" in db_url:
59
+ connection_url = f"{db_url}&authToken={auth_token.strip()}"
60
+ else:
61
+ connection_url = f"{db_url}?authToken={auth_token.strip()}"
62
+
63
+ app.db_conn = libsql.connect(connection_url)
64
 
65
  # Test connection
66
  result = app.db_conn.execute("SELECT 1").fetchone()