Python Forum
Error when Inserting CSV file values into a postgreSQL using psycopg2
Thread Rating:
  • 3 Vote(s) - 3.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error when Inserting CSV file values into a postgreSQL using psycopg2
#4
(Oct-04-2016, 05:43 PM)klllmmm Wrote: @nilamo Thank you very much, As u point out i should take out conn.commit & cur.close from the for loop. 
Also for loop has to be change as :
if i >= 0: continue
So now all the lines CSV file printed no error pops up, but it seems nothing is inserted into PostgreSQL data table, as nothing is printed when i run a select command.

Are you sure you want to skip the loop if the index is greater than 0?  That means you're skipping every row except the first... which sounds like the opposite of what you want, which would explain why nothing is getting inserted.
Reply


Messages In This Thread
RE: Error when Inserting CSV file values into a postgreSQL using psycopg2 - by nilamo - Oct-04-2016, 05:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to Connect to PostgreSQL Through Jump Server and SSH Tunnel using Python? nishans 1 1,319 Jan-02-2024, 10:37 AM
Last Post: khanzain
  Trying to use 2 values from excel in my script but getting error.. cubangt 3 1,776 May-11-2022, 07:12 AM
Last Post: normanwolf
  Modify values in XML file by data from text file (without parsing) Paqqno 2 1,858 Apr-13-2022, 06:02 AM
Last Post: Paqqno
  Overwrite values in XML file with values from another XML file Paqqno 5 3,572 Apr-01-2022, 11:33 PM
Last Post: Larz60+
  How to split file by same values from column from imported CSV file? Paqqno 5 3,002 Mar-24-2022, 05:25 PM
Last Post: Paqqno
  How psycopg2 autocommit works ? johntay 3 10,994 Oct-08-2021, 11:22 AM
Last Post: Larz60+
  Psycopg2 doesn't work with python2 MedianykEugene 3 3,102 Aug-10-2021, 07:00 AM
Last Post: ndc85430
  Problems with inserting images into an Excel File FightingFarmer 2 3,523 May-12-2021, 10:03 PM
Last Post: FightingFarmer
  Printing x values from an csv file hobbyist 7 4,209 Mar-10-2021, 02:00 PM
Last Post: hobbyist
  Argparse error when inputting values tqader 2 3,002 Sep-11-2020, 07:42 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020