Update login.py
This commit is contained in:
parent
1945dbe65c
commit
a4c07273d9
38
login.py
38
login.py
@ -1,26 +1,24 @@
|
|||||||
from sqlalchemy import *
|
import datetime
|
||||||
from sqlalchemy import create_engine, ForeignKey
|
from sqlalchemy import create_engine
|
||||||
from sqlalchemy import Column, Date, Integer, String
|
from sqlalchemy.orm import sessionmaker
|
||||||
from sqlalchemy.ext.declarative import declarative_base
|
from tabledef import *
|
||||||
from sqlalchemy.orm import relationship, backref
|
|
||||||
|
|
||||||
engine = create_engine('sqlite:///tutorial.db', echo=True)
|
engine = create_engine('sqlite:///tutorial.db', echo=True)
|
||||||
Base = declarative_base()
|
|
||||||
|
|
||||||
########################################################################
|
# create a Session
|
||||||
class User(Base):
|
Session = sessionmaker(bind=engine)
|
||||||
""""""
|
session = Session()
|
||||||
__tablename__ = "users"
|
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True)
|
user = User("admin","password")
|
||||||
username = Column(String)
|
session.add(user)
|
||||||
password = Column(String)
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
user = User("python","python")
|
||||||
def __init__(self, username, password):
|
session.add(user)
|
||||||
""""""
|
|
||||||
self.username = username
|
|
||||||
self.password = password
|
|
||||||
|
|
||||||
# create tables
|
user = User("jumpiness","python")
|
||||||
Base.metadata.create_all(engine)
|
session.add(user)
|
||||||
|
|
||||||
|
# commit the record the database
|
||||||
|
session.commit()
|
||||||
|
|
||||||
|
session.commit()
|
||||||
|
Loading…
Reference in New Issue
Block a user