paleolimbot commented on issue #2093:
URL: https://github.com/apache/arrow-adbc/issues/2093#issuecomment-2302242172

   Thank you for reporting!
   
   In the forthcoming release we'll have a workaround for queries not supported 
by COPY, although we probably need to do some work to integrate the option into 
dbapi. The workaround in the current development version might look like:
   
   ```python
   import adbc_driver_postgresql.dbapi
   
   con = adbc_driver_postgresql.dbapi.connect(
       
uri="postgresql://localhost:5432/postgres?user=postgres&password=password"
   )
   
   with con.cursor() as cur:
       cur.adbc_statement.set_options(**{"adbc.postgresql.use_copy": "false"})
       cur.execute("show all")
       df = cur.fetch_df()
   
   df
   ```
   
   <img width="607" alt="Screenshot 2024-08-21 at 11 49 35 AM" 
src="https://github.com/user-attachments/assets/5fb5d265-0ba0-4a8e-a6bb-26bf095dddd2";>
   
   In R the workaround would look like:
   
   ``` r
   library(adbcdrivermanager)
   
   con <- adbc_database_init(
     adbcpostgresql::adbcpostgresql(), 
     uri = 
"postgresql://localhost:5432/postgres?user=postgres&password=password"
   ) |> 
     adbc_connection_init()
   
   out <- nanoarrow::nanoarrow_allocate_array_stream()
   con |> 
     adbc_statement_init(
       "adbc.postgresql.use_copy" = "false"
     ) |> 
     adbc_statement_set_sql_query("SHOW ALL") |> 
     adbc_statement_execute_query(out)
   #> [1] -1
   tibble::as_tibble(out)
   #> # A tibble: 362 × 3
   #>    name                       setting      description                    
      
   #>    <chr>                      <chr>        <chr>                          
      
   #>  1 allow_in_place_tablespaces "off"        Allows tablespaces directly 
inside p…
   #>  2 allow_system_table_mods    "off"        Allows modifications of the 
structur…
   #>  3 application_name           ""           Sets the application name to 
be repo…
   #>  4 archive_cleanup_command    ""           Sets the shell command that 
will be …
   #>  5 archive_command            "(disabled)" Sets the shell command that 
will be …
   #>  6 archive_library            ""           Sets the library that will be 
called…
   #>  7 archive_mode               "off"        Allows archiving of WAL files 
using …
   #>  8 archive_timeout            "0"          Sets the amount of time to 
wait befo…
   #>  9 array_nulls                "on"         Enable input of NULL elements 
in arr…
   #> 10 authentication_timeout     "1min"       Sets the maximum allowed time 
to com…
   #> # ℹ 352 more rows
   ```
   
   <sup>Created on 2024-08-21 with [reprex 
v2.1.1](https://reprex.tidyverse.org)</sup>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to