adding validated services? patching forcad_local.py
This commit is contained in:
31
ctfcup24-school-ad/services/filtranator/server/app/db.py
Normal file
31
ctfcup24-school-ad/services/filtranator/server/app/db.py
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/python3
|
||||
import psycopg2
|
||||
import sys
|
||||
|
||||
class LocalDb:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def connect(self,conn_string):
|
||||
#try:
|
||||
self.conn = psycopg2.connect(
|
||||
conn_string
|
||||
)
|
||||
#except Exception as e:
|
||||
#print(e)
|
||||
|
||||
def execute(self, command):
|
||||
cursor = self.conn.cursor()
|
||||
#try:
|
||||
cursor.execute(command)
|
||||
try:
|
||||
result = cursor.fetchall()
|
||||
except Exception as e:
|
||||
print(e,file=sys.stderr)
|
||||
result = []
|
||||
#cursor.close()
|
||||
return result
|
||||
|
||||
def disconnect(self):
|
||||
self.conn.cursor.close()
|
||||
self.conn.close()
|
||||
Reference in New Issue
Block a user