From 7bdd4b5cdd4c83131431f726c580f345ab263f40 Mon Sep 17 00:00:00 2001 From: BBaoVanC Date: Sun, 4 Oct 2020 11:19:53 -0500 Subject: [PATCH] Remove versiontest.py --- versiontest.py | 54 -------------------------------------------------- 1 file changed, 54 deletions(-) delete mode 100644 versiontest.py diff --git a/versiontest.py b/versiontest.py deleted file mode 100644 index 4f0b00a..0000000 --- a/versiontest.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python3 -""" -libinv - -Library for interacting with inventory database. -""" - -# Imports -import psycopg2 -from configparser import ConfigParser - -def config(filename="postgres.ini", section="postgresql"): - parser = ConfigParser() - parser.read(filename) - - db = {} - if parser.has_section(section): - params = parser.items(section) - for param in params: - db[param[0]] = param[1] - else: - raise Exception('Section {0} not found in the {1} file'.format(section, filename)) - - return db - - -def connect(): - """ Connect to the PostgreSQL database server """ - conn = None - try: - params = config() - - print("Connecting to the PostgreSQL database...") - conn = psycopg2.connect(**params) - - cur = conn.cursor() - - # execute a statement - print("Postgres version:") - cur.execute("SELECT version()") - - # display the database version - db_version = cur.fetchone() - print(db_version) - except (Exception, psycopg2.DatabaseError) as e: - print(e) - finally: - if conn is not None: - conn.close() - print("Database connection closed.") - - -if __name__ == '__main__': - connect()