From 8f2d9faf1e1b5eba699e31a2925c4b1e3c328d13 Mon Sep 17 00:00:00 2001 From: Mikayla Dobson <93477693+innocuous-symmetry@users.noreply.github.com> Date: Sat, 7 Jan 2023 19:58:47 -0600 Subject: [PATCH] basic formatting for pgutil --- postgresutil.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 postgresutil.py diff --git a/postgresutil.py b/postgresutil.py new file mode 100644 index 0000000..48bc63a --- /dev/null +++ b/postgresutil.py @@ -0,0 +1,29 @@ +import psycopg2 +from config import Config + +def postgresutil(config: Config): + pg_config = config.pg_config + + if pg_config is None: + raise Exception("Insufficient data to establish PostgreSQL connection.") + + conn = psycopg2.connect(pg_config.dsn) + + # TO DO: script to create these tables and interact with them + + """ + CREATE TABLE IF NOT EXISTS label ( + id INT PRIMARY KEY, + name varchar + ); + + CREATE TABLE IF NOT EXISTS photo ( + id INT PRIMARY KEY, + path varchar, + label varchar, + matchstrength decimal, + labelid INT REFERENCES label(id) + ); + """ + + return conn \ No newline at end of file