From a4c07273d9c682e17be0e81da2e62f0a7daecf63 Mon Sep 17 00:00:00 2001 From: Logan Hunt Date: Tue, 27 Mar 2018 09:32:17 -0600 Subject: [PATCH] Update login.py --- login.py | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/login.py b/login.py index bfe0355..b50138e 100644 --- a/login.py +++ b/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()