Skip to content

Commit

Permalink
test moving db connection files
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgiolaga committed May 28, 2023
1 parent 1463f09 commit 9b0ed1f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
File renamed without changes.
File renamed without changes.
7 changes: 6 additions & 1 deletion db/connection.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import psycopg2
from db.config import config
from config import config

def connect():
conn = None
try:
params = config()
print('Connecting to the PostgreSQL database...')
conn = psycopg2.connect(**params)
conn.autocommit = True
cur = conn.cursor()
print('PostgreSQL database version:')
cur.execute('SELECT version()')
db_version = cur.fetchone()
print(db_version)
return cur
except (Exception, psycopg2.DatabaseError) as error:
print("There was an issue during the db connection:")
Expand Down

0 comments on commit 9b0ed1f

Please sign in to comment.