I am trying to get data from a dataFrame to postgres. I have all the data loaded in the dataframe, but when inserting it in postgres it gives me formatting problems.
I have the table created like this:
CREATE TABLE IF NOT EXISTS DL.desempleo (id varchar(2) NOT NULL, Periodo VARCHAR (10) NOT NULL, Total DECIMAL);
And insert like this:
INSERT INTO DL.desempleo (id,Periodo, Total) values (%s,%s,%d)
Can someone tell me with what format I put the Total value, which is Decimal (7.55), if I put it as %d it gives me the following error:
Error al conectar con PostgreSQL unsupported format character 'd' (0x64) at index %Id
You can replace the
%d
with%s
, in the questions and answers about the use ofpsycopg
is commented: https://www.psycopg.org/docs/faq.html#problems-with-type-conversions