Moved the config management to its own class.feature/embed-uploads
parent
bae4f0e42a
commit
68d2055707
@ -1 +1,2 @@ |
|||||||
config.json |
config.json |
||||||
|
db.sqlite |
||||||
|
@ -1,5 +1,8 @@ |
|||||||
{ |
{ |
||||||
"MAIN": { |
"MAIN": { |
||||||
"WEBHOOK_URL": "" |
"WEBHOOK_URL": "" |
||||||
|
}, |
||||||
|
"DATABASE": { |
||||||
|
"CONNECTION_STRING": "" |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -0,0 +1,12 @@ |
|||||||
|
from sqlalchemy import Column, String, Integer, Date |
||||||
|
from sqlalchemy.ext.declarative import declarative_base |
||||||
|
from database_session import Base |
||||||
|
|
||||||
|
class DiscordChannel(Base): |
||||||
|
__tablename__ = 'discord_channels' |
||||||
|
|
||||||
|
id = Column(Integer, primary_key=True) |
||||||
|
channel_id = Column(Integer) |
||||||
|
|
||||||
|
def __init__(self, channel_id): |
||||||
|
self.channel_id = channel_id |
@ -0,0 +1,16 @@ |
|||||||
|
from sqlalchemy import create_engine |
||||||
|
from sqlalchemy.ext.declarative import declarative_base |
||||||
|
from sqlalchemy.orm import sessionmaker |
||||||
|
|
||||||
|
_engine = None |
||||||
|
Base = declarative_base() |
||||||
|
|
||||||
|
def initialize(config): |
||||||
|
global _engine |
||||||
|
_connection_string = config.database_connection_string |
||||||
|
_engine = create_engine(_connection_string) |
||||||
|
Base.metadata.create_all(_engine) |
||||||
|
|
||||||
|
def get_session(): |
||||||
|
Session = sessionmaker(bind=_engine)() |
||||||
|
return Session |
Loading…
Reference in new issue