Spaces:
Sleeping
Sleeping
import sqlite3 | |
from pandas import DataFrame | |
DB_FILENAME = 'irembo_application_4.db' | |
def run_query(query=''): | |
clean_query = query.replace('```','') | |
print(f"clean_query \n {clean_query}") | |
conn = sqlite3.connect(DB_FILENAME) | |
cursor = conn.cursor() | |
cursor.execute(clean_query) | |
#data = cursor.fetchall() | |
#print(data) | |
#conn.close() | |
print(f"Cursor Description \n {cursor.description}") | |
df = DataFrame(cursor.fetchall()) | |
print(df.head()) | |
df.columns = [i[0] for i in cursor.description] | |
# print(f'Field Names : {field_names}') | |
print(df.head()) | |
conn.close() | |
return df |