pandas icon indicating copy to clipboard operation
pandas copied to clipboard

DOC: Improvement for def psql_insert_copy(table, conn, keys, data_iter)

Open try-and-succeed opened this issue 1 year ago • 3 comments

Pandas version checks

  • [X] I have checked that the issue still exists on the latest versions of the docs on main here

Location of the documentation

https://pandas.pydata.org/pandas-docs/stable/user_guide/io.html#insertion-method

Documentation problem

The function psql_insert_copy does not work for capitalized schema names and table names. The fix is quite easy.

Suggested fix for documentation

To work with capitalized letters in schema name and table name the function should get changed from

    if table.schema:
        table_name = '{}.{}'.format(table.schema, table.name)
    else:
        table_name = table.name

to

    if table.schema:
        table_name = '"{}"."{}"'.format(table.schema, table.name)
    else:
        table_name = '"{}"'.format(table.name)

try-and-succeed avatar Jun 29 '23 22:06 try-and-succeed

Following!

rsm-23 avatar Jul 01 '23 18:07 rsm-23

This should be closed.

linus-md avatar Dec 08 '23 09:12 linus-md

Suggest to fix the documentation for how to add data through the pattern of arguments at: psql_insert_copy(table, conn, keys, data_iter). It was asked in Stackoverflow also in 2020, but no answer found so far. https://stackoverflow.com/questions/23103962/how-to-write-dataframe-to-postgres-table#comment106687523_55495065

corinabioinformatic avatar May 09 '24 16:05 corinabioinformatic