1
0
Fork 0

Add database on bot

This commit is contained in:
Ethanell 2020-05-27 23:08:23 +02:00
parent c9d56ca8f5
commit d014e9666c
4 changed files with 16 additions and 1 deletions

View file

@ -1,4 +1,5 @@
from bot_bde.config import config
import db
from discord.ext import commands
bot = commands.Bot(command_prefix=config.get("prefix"))

View file

@ -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
View 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)

View file

@ -8,3 +8,4 @@ idna==2.9
multidict==4.7.5
websockets==8.1
yarl==1.4.2
SQLAlchemy~=1.3.17