GitHub user michalc edited a discussion: Getting results from `SHOW` queries in
Python + PostgreSQL
I'm wanting to run `SHOW` queries from Python on a PostgreSQL database, but am
running into problems. Specifically running:
```python
import adbc_driver_postgresql.dbapi as db
with db.connect('postgresql://postgres:[email protected]:5432/') as conn:
with conn.cursor() as cur:
cur.execute('SHOW TRANSACTION ISOLATION LEVEL')
```
results in an error, the key bits of which seem to be:
```
Traceback (most recent call last):
File [...], line 5, in <module>
cur.execute('SHOW TRANSACTION ISOLATION LEVEL')
File "[...]", line 730, in execute
handle, self._rowcount = _blocking_call(
^^^^^^^^^^^^^^^
File "adbc_driver_manager/_lib.pyx", line 1606, in
adbc_driver_manager._lib._blocking_call_impl
File "adbc_driver_manager/_lib.pyx", line 1599, in
adbc_driver_manager._lib._blocking_call_impl
File "adbc_driver_manager/_lib.pyx", line 1241, in
adbc_driver_manager._lib.AdbcStatement.execute_query
File "adbc_driver_manager/_lib.pyx", line 260, in
adbc_driver_manager._lib.check_error
adbc_driver_manager.ProgrammingError: INVALID_ARGUMENT: [libpq] Failed to
execute query: could not begin COPY: ERROR: syntax error at or near "SHOW"
LINE 1: COPY (SHOW TRANSACTION ISOLATION LEVEL) TO STDOUT (FORMAT bi...
^
Query was: COPY (SHOW TRANSACTION ISOLATION LEVEL) TO STDOUT (FORMAT binary).
SQLSTATE: 42601
```
It looks like it tries to the the `SHOW` as a `COPY`, but this isn't allowed.
Is there a way around this, say for example by _not_ running the queries as a
`COPY`?
(Context: am writing a SQLAlchemy dialect, and the SQLAlchemy existing base
PostgreSQL dialect tries to run such queries)
GitHub link: https://github.com/apache/arrow-adbc/discussions/2857
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]