Created
July 8, 2020 08:01
-
-
Save dimastatz/89cd4f4cf0e5a40be8e01ac863300be3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_db_client(host, user, password, db): | |
import psycopg2 | |
return psycopg2.connect(host=host, user=user, password=password, dbname=db) | |
def insert_to_db(conn, table, values: list): | |
v = ['({}),'.format(y for y in x) for x in values] | |
sql = 'insert into {} values {}'.format(table, v) | |
cur = conn.cursor() | |
cur.execute(sql) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment