django-sql-dashboard
django-sql-dashboard copied to clipboard
django_sql_dashboard fails with psycopg3
trafficstars
django_sql_dashboard fails with psycopg3 because of ModuleNotFoundError:
./django_sql_dashboard/views.py:from psycopg2.extensions import quote_ident
I take it this is a reexport?
In psycopg3 that would be something like this:
import psycopg
from psycopg import sql
# Example table name
table_name = "my_table"
# Quoting an identifier
quoted_identifier = sql.Identifier(table_name)
# Using the quoted identifier in a query
query = sql.SQL("SELECT * FROM {}").format(quoted_identifier)
# Connect to the database (using psycopg3)
with psycopg.connect("dbname=test user=postgres") as conn:
with conn.cursor() as cur:
cur.execute(query)
result = cur.fetchall()
print(result)
Not sure whether that's easy to support, but I'd at least make the import quote_ident not fatal.
From a quick test, django_sql_dashboard seems to work fine with psycopg3 as well, if that were to be changed.