Spaces:
Build error
Build error
Update script.py
Browse files
script.py
CHANGED
|
@@ -1,24 +1,15 @@
|
|
| 1 |
import os
|
| 2 |
from langchain import OpenAI, SQLDatabase, SQLDatabaseChain
|
| 3 |
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
, include_tables=['Album', 'Track']
|
| 8 |
-
)
|
| 9 |
|
| 10 |
-
|
|
|
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
)
|
| 17 |
-
|
| 18 |
-
queries = ("How many albums are there?"
|
| 19 |
-
, "How many tracks are there?"
|
| 20 |
-
, "Which album has the most tracks?"
|
| 21 |
-
)
|
| 22 |
-
|
| 23 |
-
for query in queries:
|
| 24 |
-
print(db_chain.run(query))
|
|
|
|
| 1 |
import os
|
| 2 |
from langchain import OpenAI, SQLDatabase, SQLDatabaseChain
|
| 3 |
|
| 4 |
+
import sqlite3
|
| 5 |
+
import streamlit as st
|
| 6 |
|
| 7 |
+
st.title("English to SQL via LangChain")
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
tables = ['Album', 'Artist', 'Track']
|
| 10 |
+
db = SQLDatabase.from_uri("sqlite:///Chinook.db", include_tables=tables)
|
| 11 |
|
| 12 |
+
con = sqlite3.connect("Chinook.db")
|
| 13 |
+
for table in tables:
|
| 14 |
+
rows = cur.execute("select * from %s limit 5" %s table).fetchall()
|
| 15 |
+
st.table(rows)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|