Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

django_sql_dashboard fails with psycopg3 #162

Open
daym opened this issue Dec 7, 2024 · 0 comments
Open

django_sql_dashboard fails with psycopg3 #162

daym opened this issue Dec 7, 2024 · 0 comments

Comments

@daym
Copy link

daym commented Dec 7, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant