datacipen commited on
Commit
6ac0fc9
·
verified ·
1 Parent(s): b2774c5

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +4 -2
main.py CHANGED
@@ -3,6 +3,7 @@ import json
3
  import bcrypt
4
  import pandas as pd
5
  import numpy as np
 
6
  from typing import List
7
  from pathlib import Path
8
 
@@ -29,6 +30,7 @@ literal_client = LiteralClient(api_key=os.getenv("LITERAL_API_KEY"))
29
 
30
  from surveycaa import surveyCaa
31
 
 
32
  @cl.password_auth_callback
33
  def auth_callback(username: str, password: str):
34
  auth = json.loads(os.environ['CHAINLIT_AUTH_LOGIN'])
@@ -65,8 +67,8 @@ def create_agent(filename: str):
65
  # Read the CSV file into a Pandas DataFrame.
66
  if cl.user_session.get("createdb") == None:
67
  df = pd.read_csv(filename)
68
- engine = create_engine("sqlite:///sphinx.db")
69
- df.to_sql("sphinx", engine, index=False)
70
  db = SQLDatabase(engine=engine)
71
  cl.user_session.set("createdb", "OK")
72
  cl.user_session.set("db", db)
 
3
  import bcrypt
4
  import pandas as pd
5
  import numpy as np
6
+ import random
7
  from typing import List
8
  from pathlib import Path
9
 
 
30
 
31
  from surveycaa import surveyCaa
32
 
33
+ id_sphinx = random.randint(100, 10000)
34
  @cl.password_auth_callback
35
  def auth_callback(username: str, password: str):
36
  auth = json.loads(os.environ['CHAINLIT_AUTH_LOGIN'])
 
67
  # Read the CSV file into a Pandas DataFrame.
68
  if cl.user_session.get("createdb") == None:
69
  df = pd.read_csv(filename)
70
+ engine = create_engine("sqlite:///sphinx" + id_sphinx + ".db")
71
+ df.to_sql("sphinx" + id_sphinx, engine, index=False)
72
  db = SQLDatabase(engine=engine)
73
  cl.user_session.set("createdb", "OK")
74
  cl.user_session.set("db", db)