2019-12-16 17:12:10 +00:00
|
|
|
from .config import Config
|
|
|
|
|
2020-01-15 21:56:54 +00:00
|
|
|
import sqlalchemy
|
|
|
|
import databases
|
2019-10-06 21:49:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Database:
|
2019-12-16 17:12:10 +00:00
|
|
|
def __init__(self, config: Config):
|
|
|
|
conf_postgresql = config["postgresql"]
|
|
|
|
postgresql = 'postgresql://{}:{}@{}/{}'.format(
|
|
|
|
conf_postgresql.get("Username"), conf_postgresql.get("Password"),
|
|
|
|
conf_postgresql.get("Host"), conf_postgresql.get("DBName"))
|
2019-10-06 21:49:00 +00:00
|
|
|
|
2020-01-15 21:56:54 +00:00
|
|
|
self.database = databases.Database(postgresql)
|
|
|
|
self.metadata = sqlalchemy.MetaData()
|
|
|
|
self.engine = sqlalchemy.create_engine(str(self.database.url))
|