Spaces:
Configuration error
Configuration error
Al-Fathir
commited on
Commit
·
c92e861
1
Parent(s):
fd57848
add demo databases
Browse files
agents.py
CHANGED
@@ -14,10 +14,11 @@ def set_connection(conn):
|
|
14 |
connection = conn
|
15 |
|
16 |
|
17 |
-
def createConnection(user='root',password='password',host='127.0.0.1',database='sakila'):
|
18 |
cnx = mysql.connector.connect(user=user, password=password,
|
19 |
host=host,
|
20 |
-
database=database
|
|
|
21 |
|
22 |
return cnx
|
23 |
|
|
|
14 |
connection = conn
|
15 |
|
16 |
|
17 |
+
def createConnection(user='root',password='password',host='127.0.0.1',port='3306',database='sakila'):
|
18 |
cnx = mysql.connector.connect(user=user, password=password,
|
19 |
host=host,
|
20 |
+
database=database,
|
21 |
+
port=port)
|
22 |
|
23 |
return cnx
|
24 |
|
app.py
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
import gradio as gr
|
2 |
from agents import agent, createConnection, getAllTable, Inference, set_connection
|
3 |
|
4 |
-
def connect(username, password, host, database):
|
5 |
print("test")
|
6 |
global conn
|
7 |
-
conn = createConnection(username, password, host, database)
|
8 |
set_connection(conn)
|
9 |
if conn:
|
10 |
tables = getAllTable(conn) # Mengambil data setelah koneksi berhasil
|
@@ -32,11 +32,12 @@ with gr.Blocks() as demo:
|
|
32 |
|
33 |
with gr.Tab("Database"):
|
34 |
gr.Markdown("### Database Connection")
|
35 |
-
gr.Markdown("Use only a cloud-hosted MySQL server (local servers are not supported).\n\nYou can use the demo server
|
36 |
-
host = gr.Textbox(placeholder="http://127.0.0.1/", label="Host")
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
40 |
|
41 |
toast = gr.Markdown(visible=False) # Feedback setelah tombol ditekan
|
42 |
btn = gr.Button("Connect")
|
@@ -44,6 +45,6 @@ with gr.Blocks() as demo:
|
|
44 |
gr.Markdown("### Database Info")
|
45 |
tables_output = gr.Textbox(visible=False) # Awalnya disembunyikan
|
46 |
|
47 |
-
btn.click(fn=connect, inputs=[username, password, host, database], outputs=[state, toast, tables_output])
|
48 |
|
49 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from agents import agent, createConnection, getAllTable, Inference, set_connection
|
3 |
|
4 |
+
def connect(username, password, host,port, database):
|
5 |
print("test")
|
6 |
global conn
|
7 |
+
conn = createConnection(username, password, host,port, database)
|
8 |
set_connection(conn)
|
9 |
if conn:
|
10 |
tables = getAllTable(conn) # Mengambil data setelah koneksi berhasil
|
|
|
32 |
|
33 |
with gr.Tab("Database"):
|
34 |
gr.Markdown("### Database Connection")
|
35 |
+
gr.Markdown("Use only a cloud-hosted MySQL server (local servers are not supported).\n\nYou can use the demo server (if desired).")
|
36 |
+
host = gr.Textbox(placeholder="http://127.0.0.1/", label="Host", value='mysql-13c1c04a-alfthr378-61ca.d.aivencloud.com')
|
37 |
+
port = gr.Textbox(placeholder="Port", label="Port", value='16222')
|
38 |
+
username = gr.Textbox(placeholder="Username", label="Username", value='chatsqlrek')
|
39 |
+
password = gr.Textbox(placeholder="Password", type="password", label="Password", value='123456789')
|
40 |
+
database = gr.Textbox(placeholder="Database", label="Database", value='sakila')
|
41 |
|
42 |
toast = gr.Markdown(visible=False) # Feedback setelah tombol ditekan
|
43 |
btn = gr.Button("Connect")
|
|
|
45 |
gr.Markdown("### Database Info")
|
46 |
tables_output = gr.Textbox(visible=False) # Awalnya disembunyikan
|
47 |
|
48 |
+
btn.click(fn=connect, inputs=[username, password, host,port, database], outputs=[state, toast, tables_output])
|
49 |
|
50 |
demo.launch()
|