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 *
|
||||
from sqlalchemy import create_engine, ForeignKey
|
||||
from sqlalchemy import Column, Date, Integer, String
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import relationship, backref
|
||||
import datetime
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from tabledef import *
|
||||
|
||||
engine = create_engine('sqlite:///tutorial.db', echo=True)
|
||||
Base = declarative_base()
|
||||
|
||||
########################################################################
|
||||
class User(Base):
|
||||
""""""
|
||||
__tablename__ = "users"
|
||||
# create a Session
|
||||
Session = sessionmaker(bind=engine)
|
||||
session = Session()
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
username = Column(String)
|
||||
password = Column(String)
|
||||
user = User("admin","password")
|
||||
session.add(user)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def __init__(self, username, password):
|
||||
""""""
|
||||
self.username = username
|
||||
self.password = password
|
||||
user = User("python","python")
|
||||
session.add(user)
|
||||
|
||||
# create tables
|
||||
Base.metadata.create_all(engine)
|
||||
user = User("jumpiness","python")
|
||||
session.add(user)
|
||||
|
||||
# commit the record the database
|
||||
session.commit()
|
||||
|
||||
session.commit()
|
||||
|
Loading…
Reference in New Issue
Block a user