I recently started using Macbook because my laptop was changed at work and right after that I started having problems with some of my code that I use to upload a dataframe to a postgresql database.
import psycopg2 from io import StringIO def create_connection(user,password): return psycopg2.connect( host='HOST', database='DBNAME', user=user, password=password) conn = create_connection(user,password) table = "data_analytics.tbl_summary_wingmans_rt" buffer = StringIO() df.to_csv(buffer, header=False, index=False) buffer.seek(0) cursor = conn.cursor() cursor.copy_from(buffer, table, sep=",", null="") conn.commit() cursor.close()
As you can see, the code is quite simple and even before the change of equipment it ran without major problem on Windows. But as soon as I run this same code on the mac it throws me the following error:
Error: relation "data_analytics.tbl_summary_wingmans_rt" does not exist
In several posts I saw that it could be the use of double quotes but I have already used the following and I still do not have a positive result.
"data_analytics."tbl_summary_wingmans_rt"" ""data_analytics"."tbl_summary_wingmans_rt"" 'data_analytics."tbl_summary_wingmans_rt"'
The behaviour of
copy_from changed in psycopg2 2.9 to properly quote the table name, which means that you can no longer supply a schema-qualified table name that way; you have to use