Spaces:
Running
Running
liquidcarbon
commited on
Commit
•
5a864fe
1
Parent(s):
1873f22
itoptions styling
Browse files
main.py
CHANGED
@@ -17,6 +17,10 @@ from sql import Q
|
|
17 |
itoptions.classes = "display compact cell-border"
|
18 |
itoptions.column_filters = "footer"
|
19 |
|
|
|
|
|
|
|
|
|
20 |
EXAMPLE1 = """
|
21 |
SELECT
|
22 |
Symbol,
|
@@ -39,12 +43,12 @@ def query_db(base64query: str|None = None):
|
|
39 |
"""Endpoint for running b64-encoded SQL queries."""
|
40 |
decoded = Q.from_base64(base64query)
|
41 |
df = decoded.df()
|
42 |
-
html = to_html_datatable(df)
|
43 |
return f"""
|
44 |
<head>
|
45 |
-
|
46 |
</head>
|
47 |
-
<div>{html}</div>
|
48 |
<hr><pre>{decoded}</pre>
|
49 |
"""
|
50 |
|
@@ -85,13 +89,13 @@ with gr.Blocks(
|
|
85 |
css="#resultContainer {height: 75vh;}"
|
86 |
) as gradio_sql_interface:
|
87 |
with gr.Row():
|
88 |
-
with gr.Column(scale=1):
|
89 |
header = gr.Markdown("# SQL Editor")
|
90 |
sql_code = gr.Code(language="sql", label="SQL Query", lines=32, interactive=True)
|
91 |
button = gr.Button("run")
|
92 |
editor_url = gr.Code(label="Share Editor URL", lines=1)
|
93 |
query_url = gr.Code(label="Share Query Results URL", lines=1)
|
94 |
-
with gr.Column(scale=
|
95 |
markdown = gr.Markdown("# RESULTS")
|
96 |
results = gr.HTML()
|
97 |
button.click(query_from_request, [sql_code], [sql_code, editor_url, query_url, results])
|
|
|
17 |
itoptions.classes = "display compact cell-border"
|
18 |
itoptions.column_filters = "footer"
|
19 |
|
20 |
+
HEAD = """
|
21 |
+
"""
|
22 |
+
# <link rel="stylesheet" href="https://cdn.datatables.net/2.0.5/css/dataTables.dataTables.min.css" />
|
23 |
+
|
24 |
EXAMPLE1 = """
|
25 |
SELECT
|
26 |
Symbol,
|
|
|
43 |
"""Endpoint for running b64-encoded SQL queries."""
|
44 |
decoded = Q.from_base64(base64query)
|
45 |
df = decoded.df()
|
46 |
+
html = to_html_datatable(df, buttons=["copyHtml5"])
|
47 |
return f"""
|
48 |
<head>
|
49 |
+
{HEAD}
|
50 |
</head>
|
51 |
+
<div style="width:95vh;">{html}</div>
|
52 |
<hr><pre>{decoded}</pre>
|
53 |
"""
|
54 |
|
|
|
89 |
css="#resultContainer {height: 75vh;}"
|
90 |
) as gradio_sql_interface:
|
91 |
with gr.Row():
|
92 |
+
with gr.Column(scale=1, min_width=420):
|
93 |
header = gr.Markdown("# SQL Editor")
|
94 |
sql_code = gr.Code(language="sql", label="SQL Query", lines=32, interactive=True)
|
95 |
button = gr.Button("run")
|
96 |
editor_url = gr.Code(label="Share Editor URL", lines=1)
|
97 |
query_url = gr.Code(label="Share Query Results URL", lines=1)
|
98 |
+
with gr.Column(scale=1, min_width=540):
|
99 |
markdown = gr.Markdown("# RESULTS")
|
100 |
results = gr.HTML()
|
101 |
button.click(query_from_request, [sql_code], [sql_code, editor_url, query_url, results])
|