Add database on bot
This commit is contained in:
parent
c9d56ca8f5
commit
d014e9666c
4 changed files with 16 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
||||||
from bot_bde.config import config
|
from bot_bde.config import config
|
||||||
|
import db
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
bot = commands.Bot(command_prefix=config.get("prefix"))
|
bot = commands.Bot(command_prefix=config.get("prefix"))
|
||||||
|
|
|
@ -1 +1,5 @@
|
||||||
{"prefix": "!", "token": "GOOD_BOT_TOKEN", "admin_id": 1234567890}
|
{"prefix": "!",
|
||||||
|
"token": "GOOD_BOT_TOKEN",
|
||||||
|
"admin_id": 1234567890,
|
||||||
|
"db": "postgresql://usr:pass@localhost:5432/sqlalchemy"
|
||||||
|
}
|
9
db/__init__.py
Normal file
9
db/__init__.py
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
from bot_bde.config import config
|
||||||
|
from sqlalchemy import create_engine
|
||||||
|
from sqlalchemy.orm import sessionmaker
|
||||||
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
|
engine = create_engine(config.get("db"))
|
||||||
|
Session = sessionmaker(bind=engine)
|
||||||
|
Base = declarative_base()
|
||||||
|
#from db.foo import Barr
|
||||||
|
Base.metadata.create_all(engine)
|
|
@ -8,3 +8,4 @@ idna==2.9
|
||||||
multidict==4.7.5
|
multidict==4.7.5
|
||||||
websockets==8.1
|
websockets==8.1
|
||||||
yarl==1.4.2
|
yarl==1.4.2
|
||||||
|
SQLAlchemy~=1.3.17
|
||||||
|
|
Reference in a new issue