Guest User

Untitled

a guest
Jan 30th, 2019
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. import psycopg2, json
  2. conn = psycopg2.connect("dbname=dbname user=user password=pass")
  3. cr = conn.cursor()
  4. filename = "linkedin.json"
  5. file = open(filename, 'r')
  6. for line in file:
  7. string_query = """('%s')""" % (str(line).replace("'", ""))
  8. query = """
  9. INSERT INTO linkedin (info)
  10. VALUES %s;
  11. """ % (string_query)
  12. cr.execute(query)
  13. conn.commit()
Add Comment
Please, Sign In to add comment