aboutsummaryrefslogblamecommitdiffstats
path: root/todb.py
blob: d911a29217495f5058b1b1614720d86f5ea07352 (plain) (tree)


















                                                                                             
#!/usr/bin/env python3

import os
import psycopg

pg_db = os.environ['el_pg_db']
pg_host = os.environ['el_pg_host']
pg_user = os.environ['el_pg_user']
pg_pass = os.environ['el_pg_pass']

def todb(sql, values):
    with psycopg.connect(dbname=pg_db, host=pg_host, user=pg_user, password=pg_pass) as conn:
        if type(values) == list:
            conn.executemany(sql, values)
        elif type(values) == tuple: 
            conn.execute(sql, values)
        else:
            print("OH SHIT")
            exit()