예제 #1
0
파일: lendy.py 프로젝트: slmagicbox/PyProj
def add_item():
    if not session.get('logged_in'):
        abort(401)

    lendydata.initDB()
    ownerID = [row[0] for row in lendydata.get_members() 
               if row[1] == request.form['owner']]
    try: ownerID = ownerID[0]  
    except IndexError:
        # implies no owners match name
        # should raise eror/create new member
        ownerID = 1      # use default member for now.

    lendydata.insert_item(request.form['name'], 
                          request.form['description'],
                          ownerID,
                          request.form['price'],
                          request.form['condition'])
                         
    lendydata.closeDB()

    flash('New entry was successfully posted')
    return redirect(url_for('show_inventory'))
예제 #2
0
def add_item():
    if not session.get('logged_in'):
        abort(401)

    lendydata.initDB()
    ownerID = [
        row[0] for row in lendydata.get_members()
        if row[1] == request.form['owner']
    ]
    try:
        ownerID = ownerID[0]
    except IndexError:
        # implies no owners match name
        # should raise eror/create new member
        ownerID = 1  # use default member for now.

    lendydata.insert_item(request.form['name'], request.form['description'],
                          ownerID, request.form['price'],
                          request.form['condition'])

    lendydata.closeDB()

    flash('New entry was successfully posted')
    return redirect(url_for('show_inventory'))
예제 #3
0
def close_db(error):
    """Closes the database again at the end of the request. 
    Note the 'g' object which makes sure we only operate on 
    the current request."""
    if hasattr(g, 'sqlite_db'):
        lendydata.closeDB()
예제 #4
0
def close_db(error):
    ''' Closes the database again at the end of the request. Note that the "g"
    object which makes sure we only operate on the current request '''

    if hasattr(g, "sqllite_db"):
        lendydata.closeDB()
예제 #5
0
 def evClose(self, event=None):
     data.closeDB()
     self.top.quit()
예제 #6
0
###

ld.insert_member('Alan','*****@*****.**')
print(ld.get_members())
ld.insert_item('Python Projects','Book',6,30,'Excellent')
ld.get_items()

ld.update_item(7,Price=25)
ld.get_item_details(7)
ld.get_member_name(6)
ld.update_member(6,Name='Alan Gould')
ld.get_member_details(6)

ld.delete_member(6)  # this also shouldn't work due to referential integrity, but does...
ld.delete_item(7)
ld.delete_member(6)

ld.cursor.execute("""
    select * from item
    where OwnerID in (select id from member where name like '%e%')
    """).fetchall()

ld.cursor.execute("""
    select * from item
    where ownerid not in (select id from member where name like '%e%')
    """).fetchall()

ld.get_member_name(4)

ld.closeDB()  # gotta close or else it won't save any of the changes
예제 #7
0
def close_db(error):
    if hasattr(g, 'sqlite_db'):
        lendydata.closeDB()
예제 #8
0
 def evClose(self, event=None):
     data.closeDB()
     self.top.quit()
예제 #9
0
파일: lendy.py 프로젝트: slmagicbox/PyProj
def close_db(error):
    """Closes the database again at the end of the request. 
    Note the 'g' object which makes sure we only operate on 
    the current request."""
    if hasattr(g, 'sqlite_db'):
        lendydata.closeDB()
예제 #10
0
 def evClose(self):
     data.closeDB()
     self.top.quit()