From 8d186d39483beff64a1c11f80c6ca5e56dd7bbc5 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Wed, 1 Feb 2023 20:32:11 +0100 Subject: moving and renaming/breaking everything --- common/postgres.py | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 common/postgres.py (limited to 'common/postgres.py') diff --git a/common/postgres.py b/common/postgres.py deleted file mode 100644 index bff0720..0000000 --- a/common/postgres.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python3 -''' common functions and stuff ''' - -import os -import sys -import psycopg - -pg_db = os.environ['el_pg_db'] -pg_host = os.environ['el_pg_host'] -pg_user = os.environ.get('el_pg_user','') -pg_pass = os.environ.get('el_pg_pass','') - -def dbi(sql, values, **kwargs): - ''' insert into db ''' - verbose = bool(kwargs['verbose']) if 'verbose' in kwargs else False - # pylint: disable=E1129 - with psycopg.connect(dbname=pg_db, host=pg_host, user=pg_user, password=pg_pass) as conn: - cur = conn.cursor() - if isinstance(values, list): - cur.executemany(sql, values) - elif isinstance(values, tuple): - cur.execute(sql, values) - else: - print('`values` is a', type(values), 'but it needs to be tuple or list') - sys.exit(1) - if verbose is True: - print("Inserted and/or changed", cur.rowcount, "rows into db") - return True -- cgit v1.2.3