Guest User

Untitled

a guest
Mar 23rd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. import psycopg2
  2. def importoDB(self):
  3. self.conn = psycopg2.connect( host='ip', user='username',
  4. password='pass',
  5. dbname='dbname')
  6. self.cursor = self.conn.cursor()
  7. f = open(r'test.csv', 'r')
  8. self.cursor.copy_from(f, 'dbname', sep=';')
  9. f.close()
  10. self.conn.commit()
Add Comment
Please, Sign In to add comment