Newer
Older
from json import load
from pathlib import Path
config_path = Path("../config/")
self.driver = config['DRIVER']
self.server = config['SERVER']
self.database = config['DATABASE']
self.uid = config['UID']
self.pwd = config['PWD']
self.port = config['PORT']
self.encrypt = config['ENCRYPT']
def connect(self):
f'Driver={self.driver};'
f'Server={self.server};'
f'Database={self.database};'
f'uid={self.uid};'
f'pwd={self.pwd};'
f'port={self.port};'
f'Encrypt={self.encrypt};'
)
return connection
# How to connect to the db?
# con = SQL_Database().connect()
# quest = con.execute("SELECT table_schema || '.' || table_name FROM information_schema.tables WHERE table_type = 'BASE TABLE' AND table_schema NOT IN ('pg_catalog', 'information_schema');")
# row = quest.fetchone()
# print(row)
# quest.close()
# con.close()