Spaces:
Sleeping
Sleeping
File size: 646 Bytes
6748588 865ba19 6748588 865ba19 6748588 865ba19 6748588 865ba19 6748588 865ba19 6748588 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
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 |