Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. INSERT INTO tester VALUES ('08/09/2018 11:13', 'EMP944274823', "T'Challa", '0', "T'Challa ", 'CPY703661946', 'Prostetnic Vogon Jeltz', 'BUY', 'BK18266', 'P514605140', 'Tele Pyschic Helmets', '74', '475', '35150')
  2.  
  3. INSERT INTO tester VALUES ('08/09/2018 11:13', 'EMP944274823', "T'Challa", '0', 'T''Challa ', 'CPY703661946', 'Prostetnic Vogon Jeltz', 'BUY', 'BK18266', 'P514605140', 'Tele Pyschic Helmets', '74', '475', '35150')
  4.  
  5. quote.replace('"','''')
  6. quote.replace('"',"'")
  7. quote.replace('"',"'")
  8.  
  9. dbxl = connect(dbname=user_db,user="postgres", password="MY_SECRET",host="XXX.XX.XX.XXX", port=6667)
  10. cursor = dbxl.cursor()
  11.  
  12. with open('/home/postgres/PYSTARTERENV/example.csv', 'rt',encoding="utf8") as csvfile:
  13. reader = csv.reader(csvfile,quotechar="'")
  14.  
  15. for row in reader:
  16. query = ('INSERT INTO %s VALUES %r' %(table_name,tuple(row)))
  17. cursor.execute(query)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement