import sqlite3
import json
# Reconnect to the SQLite database
conn = sqlite3.connect('example.db')
cur = conn.cursor()
# Execute the query
cur.execute("SELECT Name, Address FROM your_table")
# Fetch all rows from the executed query
rows = cur.fetchall()
# Get column names from the cursor description
column_names = [desc[0] for desc in cur.description]
# Convert the fetched rows to a list of dictionaries
result = [dict(zip(column_names, row)) for row in rows]
# Convert the list of dictionaries to a JSON object
json_result = json.dumps(result, indent=2)
print(json_result)
# Close the cursor and connection
cur.close()
conn.close()
try this one, because i am hoping that your using sqlite3