Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env/python
- import psycopg2
- # Get a database connection
- dsn = "dbname=%s user=%s password=%s host=%s port=%s" % ('db_name','username','password','remote_host_ip','port')
- conn = psycopg2.connect(dsn)
- query = "COPY public.hiringpattern_new FROM stdin WITH CSV HEADER DELIMITER as ',' "
- cur = conn.cursor()
- with open('csv_file_path', 'r') as f:
- cur.copy_expert(sql=copy_sql, file=f)
- conn.commit()
- cur.close()
Add Comment
Please, Sign In to add comment