Spaces:
Running
Running
david-oplatka
commited on
Commit
•
f77260d
1
Parent(s):
c0f0e19
Add County Populations Table to Database Tool
Browse files
agent.py
CHANGED
@@ -71,7 +71,7 @@ def create_assistant_tools(cfg):
|
|
71 |
|
72 |
db_tools = tools_factory.database_tools(
|
73 |
tool_name_prefix = "ev",
|
74 |
-
content_description = 'Electric Vehicles in the state of Washington',
|
75 |
sql_database = SQLDatabase(create_engine('sqlite:///ev_database.db')),
|
76 |
)
|
77 |
|
|
|
71 |
|
72 |
db_tools = tools_factory.database_tools(
|
73 |
tool_name_prefix = "ev",
|
74 |
+
content_description = 'Electric Vehicles in the state of Washington and other population information',
|
75 |
sql_database = SQLDatabase(create_engine('sqlite:///ev_database.db')),
|
76 |
)
|
77 |
|
app.py
CHANGED
@@ -21,7 +21,7 @@ def setup_db():
|
|
21 |
|
22 |
with st.spinner("Loading data... Please wait..."):
|
23 |
def tables_populated() -> bool:
|
24 |
-
tables = ['ev_population', 'county_registrations', 'ev_registrations']
|
25 |
for table in tables:
|
26 |
cursor.execute(f"SELECT name FROM sqlite_master WHERE type='table' AND name='{table}'")
|
27 |
result = cursor.fetchone()
|
@@ -55,6 +55,10 @@ def setup_db():
|
|
55 |
df = load_dataset("vectara/ev-dataset", data_files="Electric_Vehicle_Title_and_Registration_Activity.csv", token=hf_token)['train'].to_pandas()
|
56 |
df.to_sql('ev_registrations', conn, if_exists='replace', index=False)
|
57 |
|
|
|
|
|
|
|
|
|
58 |
# Commit changes and close connection
|
59 |
conn.commit()
|
60 |
conn.close()
|
|
|
21 |
|
22 |
with st.spinner("Loading data... Please wait..."):
|
23 |
def tables_populated() -> bool:
|
24 |
+
tables = ['ev_population', 'county_registrations', 'ev_registrations', 'washington_population']
|
25 |
for table in tables:
|
26 |
cursor.execute(f"SELECT name FROM sqlite_master WHERE type='table' AND name='{table}'")
|
27 |
result = cursor.fetchone()
|
|
|
55 |
df = load_dataset("vectara/ev-dataset", data_files="Electric_Vehicle_Title_and_Registration_Activity.csv", token=hf_token)['train'].to_pandas()
|
56 |
df.to_sql('ev_registrations', conn, if_exists='replace', index=False)
|
57 |
|
58 |
+
# Load data into washington_population table
|
59 |
+
df = load_dataset("vectara/ev-dataset", data_files="washington_population.csv", token=hf_token)['train'].to_pandas()
|
60 |
+
df.to_sql('washington_population', conn, if_exists='replace', index=False)
|
61 |
+
|
62 |
# Commit changes and close connection
|
63 |
conn.commit()
|
64 |
conn.close()
|