2016-07-31 15:39:04 +08:00
|
|
|
import sys
|
|
|
|
sys.path.append("../src/")
|
|
|
|
from model import db,User
|
|
|
|
|
2016-08-10 15:39:32 +08:00
|
|
|
print("Query all users:")
|
2016-07-31 15:39:04 +08:00
|
|
|
users = User.query.all()
|
|
|
|
print(users)
|
2016-08-10 15:39:32 +08:00
|
|
|
newusers = []
|
|
|
|
print("Copy data to new users and set their beans to 10000...")
|
2016-07-31 15:39:04 +08:00
|
|
|
for user in users:
|
|
|
|
newuser = User(user.username,user.password,user.avatar,user.nickname,user.description,user.status,
|
|
|
|
user.e_mail,user.student_number,user.department,user.truename,user.tel,user.register_date,
|
|
|
|
user.user_group,user.auth_method)
|
2016-08-10 15:39:32 +08:00
|
|
|
newuser.beans = 10000
|
|
|
|
newusers.append(newuser)
|
|
|
|
print("Drop all table...")
|
|
|
|
db.drop_all(bind='__all__')
|
|
|
|
print("Create all tables with beans...")
|
|
|
|
setattr(User,'beans',db.Column(db.Integer))
|
|
|
|
db.create_all(bind='__all__')
|
|
|
|
for newuser in newusers:
|
2016-07-31 15:39:04 +08:00
|
|
|
db.session.add(newuser)
|
|
|
|
db.session.commit()
|
2016-08-10 15:39:32 +08:00
|
|
|
print("Update users table successfully!")
|