added group functionality
This commit is contained in:
+32
-9
@@ -1,16 +1,39 @@
|
||||
from lapp import create_app
|
||||
import sqlalchemy as sa
|
||||
from models import db, Item
|
||||
from models import db, Item, Group, User
|
||||
|
||||
app = create_app()
|
||||
app.app_context().push()
|
||||
query = sa.select(Item).where(Item.quantity == 0)
|
||||
items = db.session.scalars(query).all()
|
||||
# query = sa.select(Item).where(Item.quantity == 0)
|
||||
# items = db.session.scalars(query).all()
|
||||
|
||||
# items=Item.query.filter_by(quantity='').all()
|
||||
for i in items:
|
||||
print(f"{i.label} {i.quantity} {i.unit}")
|
||||
i.quantity = 1
|
||||
i.unit = 'x'
|
||||
# # items=Item.query.filter_by(quantity='').all()
|
||||
# for i in items:
|
||||
# print(f"{i.label} {i.quantity} {i.unit}")
|
||||
# i.quantity = 1
|
||||
# i.unit = 'x'
|
||||
|
||||
|
||||
# add column
|
||||
|
||||
# result1 = db.session.execute(sa.text('ALTER TABLE user DROP group_id'))
|
||||
# result2 = db.session.execute(sa.text('ALTER TABLE user ADD group_id INT'))
|
||||
# db.session.commit()
|
||||
|
||||
# add the first group secret
|
||||
# gr = Group(secret='102938764918372c419283764d91873246d91283746d910283746d19283764cfv')
|
||||
# db.session.add(gr)
|
||||
# db.session.commit()
|
||||
|
||||
# add the first ket to all users
|
||||
# users = User.query.all()
|
||||
# for u in users:
|
||||
# u.group_id = 1
|
||||
# db.session.commit()
|
||||
|
||||
|
||||
# add the second group secret
|
||||
# gr = Group(secret='9999')
|
||||
# db.session.add(gr)
|
||||
# db.session.commit()
|
||||
|
||||
db.session.commit()
|
||||
Reference in New Issue
Block a user