pandas
pandas copied to clipboard
DOC: Improvement for def psql_insert_copy(table, conn, keys, data_iter)
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)
Following!
This should be closed.
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