Skip to content

Commit

Permalink
PosgresHandler connection exeption fix (#141)
Browse files Browse the repository at this point in the history
some of the fuctions did not have the sslmode passed as a keyword arg,
but just string. this is now fixed.
  • Loading branch information
Trivinyx authored Apr 29, 2024
1 parent ebfe9bf commit 77b54d3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion backend/img2mapAPI/utils/core/helper/postgresSqlHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async def createDB(dnsString: str, datname: str = 'img2map'):
datname (str, optional): Name for the database. Defaults to 'img2map'.
"""
#check if the database exists, if not create it
conn = psycopg2.connect(dnsString)
conn = psycopg2.connect(dnsString, sslmode=_LocalSSLMODE)
conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
cur = conn.cursor()
cur.execute("SELECT 1 FROM pg_catalog.pg_database WHERE datname = %s", (datname,))
Expand Down
8 changes: 4 additions & 4 deletions backend/img2mapAPI/utils/storage/data/postgresSqlHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ async def update(self, id: int, data: BaseModel, type: str)->None:

if (self.setupDone == False):
await self.setup() #make sure the database is setup
conn = psycopg2.connect(self.dnsString, self.localsslmode)
conn = psycopg2.connect(self.dnsString, sslmode=self.localsslmode)
cur = conn.cursor()
if type == 'project':
try:
Expand Down Expand Up @@ -170,7 +170,7 @@ async def fetchOne(self, id: int, type: str)->Union[None, dict]:

if (self.setupDone == False):
await self.setup() #make sure the database is setup
conn = psycopg2.connect(self.dnsString, self.localsslmode)
conn = psycopg2.connect(self.dnsString, sslmode=self.localsslmode)
cur = conn.cursor()
try:
cur.execute(
Expand Down Expand Up @@ -203,7 +203,7 @@ async def fetch(self, type: str, params: dict = {})->Union[None ,list, dict]:
if (self.setupDone == False):
await self.setup()

conn = psycopg2.connect(self.dnsString, self.localsslmode)
conn = psycopg2.connect(self.dnsString, sslmode=self.localsslmode)
cur = conn.cursor()
try:
cur.execute(
Expand Down Expand Up @@ -240,7 +240,7 @@ async def fetchAll(self, type: str) ->Union[None, list]:

if (self.setupDone == False):
await self.setup()
conn = psycopg2.connect(self.dnsString, self.localsslmode)
conn = psycopg2.connect(self.dnsString, sslmode=self.localsslmode)
cur = conn.cursor()
try:
cur.execute(
Expand Down

0 comments on commit 77b54d3

Please sign in to comment.