Skip to content

Instantly share code, notes, and snippets.

@vvaezian
Last active November 22, 2020 21:13
Show Gist options
  • Save vvaezian/86c048921248174398bdc3a1a804f76c to your computer and use it in GitHub Desktop.
Save vvaezian/86c048921248174398bdc3a1a804f76c to your computer and use it in GitHub Desktop.
import psycopg2
connection = psycopg2.connect(user="USER"
, password="PASSWORD"
, port="5432"
, database="DB_NAME"
, host="HOST")
cursor = connection.cursor()
with open('ratings.tsv') as f:
f.readline()
cursor.copy_from(f, 'source_ratings')
connection.commit()
with open('episodes.tsv') as f:
f.readline()
cursor.copy_from(f, 'source_episodes')
connection.commit()
with open('basics.tsv', 'rb') as f:
f.readline()
cursor.copy_from(f, 'source_basics')
connection.commit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment