I'm triying to load data to PosgreSQL Data Base remotly by command Line in CMD, copying data from CSV file to a specific Table. It was working well but, somehow when I try to load data now, CMD throws me this error
Curiously CSV file has the "fecha_carga" field in date type as well is in the table storage in Data Base in this way, here is my try:
psql -h suggestedorder.postgres.database.azure.com -d DataAnalytics -U dev_ext@suggestedorder -c "TRUNCATE planning.env_cat_bloqueados" -c "\copy planning.env_cat_bloqueados (key, bloqueado, fecha_carga)from 'C:\Users\geradiaz.MODELO\Desktop\Envase\Catalogos\Outputs_Catalogos\Catalogo_Bloqueados\Catalogo_Bloqueados_Output.csv'with delimiter as ','
Can someone explain me what is happening here? and how could I fixed it up?
Best regards and thanks!
The @Adrian Klaver comment gave me the idea what was wrong with my command line, in effect the fields on my CSV file was taking as data, so I changed the command line specifying that my CSV file has headers by using the next instruction at the end instead with delimiter as ','
:
with (format csv, header)
So, this is the whole command line:
psql -h suggestedorder.postgres.database.azure.com -d DataAnalytics -U dev_ext@suggestedorder -c "TRUNCATE planning.env_cat_bloqueados" -c "\copy planning.env_cat_bloqueados (key, bloqueado, fecha_carga)from 'C:\Users\geradiaz.MODELO\Desktop\Envase\Catalogos\Outputs_Catalogos\Catalogo_Bloqueados\Catalogo_Bloqueados_Output.csv'with (format csv, header)
Thanks!