Spaces:
Running
Running
Handle JSON error
Browse files
app.py
CHANGED
@@ -8,6 +8,9 @@ from database import engine, receipts
|
|
8 |
|
9 |
# Fetch all data from the 'receipts' table
|
10 |
def get_receipts_table():
|
|
|
|
|
|
|
11 |
try:
|
12 |
with engine.connect() as con:
|
13 |
result = con.execute(text("SELECT * FROM receipts"))
|
@@ -22,6 +25,15 @@ def get_receipts_table():
|
|
22 |
|
23 |
@tool
|
24 |
def sql_engine(query: str) -> str:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
try:
|
26 |
with engine.connect() as con:
|
27 |
rows = con.execute(text(query)).fetchall()
|
|
|
8 |
|
9 |
# Fetch all data from the 'receipts' table
|
10 |
def get_receipts_table():
|
11 |
+
"""
|
12 |
+
Fetch all rows from the receipts table and return as a Pandas DataFrame.
|
13 |
+
"""
|
14 |
try:
|
15 |
with engine.connect() as con:
|
16 |
result = con.execute(text("SELECT * FROM receipts"))
|
|
|
25 |
|
26 |
@tool
|
27 |
def sql_engine(query: str) -> str:
|
28 |
+
"""
|
29 |
+
Executes an SQL query on the database and returns the result.
|
30 |
+
|
31 |
+
Args:
|
32 |
+
query (str): The SQL query to execute.
|
33 |
+
|
34 |
+
Returns:
|
35 |
+
str: Query result as a formatted string.
|
36 |
+
"""
|
37 |
try:
|
38 |
with engine.connect() as con:
|
39 |
rows = con.execute(text(query)).fetchall()
|