From 062944b57acfb95f02324df0b109c0b4c2817f46 Mon Sep 17 00:00:00 2001 From: slashtechno <77907286+slashtechno@users.noreply.github.com> Date: Tue, 4 Jun 2024 09:08:15 -0500 Subject: [PATCH] Fixed how the connection was returned --- src/hello_postgres/__main__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hello_postgres/__main__.py b/src/hello_postgres/__main__.py index 75f866e..a45fc7e 100644 --- a/src/hello_postgres/__main__.py +++ b/src/hello_postgres/__main__.py @@ -4,11 +4,11 @@ import dotenv import os def main(): - cursor = connect() + cursor = connect().cursor() + # cursor.execute("SELECT * FROM DB_table WHERE id = 1") def connect(): - global conn dotenv.load_dotenv() conn = psycopg2.connect( database=os.getenv('POSTGRES_DB'), @@ -17,5 +17,6 @@ def connect(): user=os.getenv('POSTGRES_USER'), password=os.getenv('POSTGRES_PASSWORD') ) + return conn main() \ No newline at end of file