Update login.py

This commit is contained in:
Logan Hunt 2018-03-27 09:32:17 -06:00 committed by GitHub
parent 1945dbe65c
commit a4c07273d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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