more db work
This commit is contained in:
parent
75775838f0
commit
405eb6f198
1 changed files with 16 additions and 0 deletions
|
@ -1,14 +1,30 @@
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
import sqlalchemy.orm
|
||||||
|
from sqlalchemy import Table, Column, Integer, String, MetaData
|
||||||
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
import json
|
import json
|
||||||
|
|
||||||
with open('config.json', 'r') as file:
|
with open('config.json', 'r') as file:
|
||||||
config = json.load(file)
|
config = json.load(file)
|
||||||
|
|
||||||
username = config['database']['username']
|
username = config['database']['username']
|
||||||
password = config['database']['password']
|
password = config['database']['password']
|
||||||
port = config['database']['port']
|
port = config['database']['port']
|
||||||
location = config['database']['location']
|
location = config['database']['location']
|
||||||
database = config['database']['database']
|
database = config['database']['database']
|
||||||
|
|
||||||
|
metadata = sqlalchemy.MetaData()
|
||||||
|
|
||||||
engine = sqlalchemy.create_engine('postgresql://' + username + ':' + password + '@' + location +':' + port + '/' + database) # todo: finish this, give users options maybe
|
engine = sqlalchemy.create_engine('postgresql://' + username + ':' + password + '@' + location +':' + port + '/' + database) # todo: finish this, give users options maybe
|
||||||
Session = sqlalchemy.orm.sessionmaker(bind=engine)
|
Session = sqlalchemy.orm.sessionmaker(bind=engine)
|
||||||
session = Session()
|
session = Session()
|
||||||
|
Base = declarative_base()
|
||||||
|
|
||||||
|
users = Table(
|
||||||
|
'users', metadata,
|
||||||
|
Column('id', Integer, primary_key = True),
|
||||||
|
Column('name', String),
|
||||||
|
Column('password', String),
|
||||||
|
)
|
||||||
|
|
||||||
|
metadata.create_all(engine)
|
||||||
|
|
Loading…
Add table
Reference in a new issue