-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchange.py.save
49 lines (40 loc) · 1.25 KB
/
change.py.save
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import datetime
import hashlib
import os
import random
import re
import sqlite3
import sys
from http.client import BAD_REQUEST
from flask import Flask, abort, g, request
from flask_admin import Admin
from flask_admin.contrib.sqla import ModelView
from flask_script import Manager
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from lxml import etree
from sqlalchemy.exc import IntegrityError
from sqlalchemy import create_engine
from exception import MyException
# 使用Flask构建web对象app
app = Flask(__name__)
# 激活app环境(with app_context()也行)
app.app_context().push()
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['PROPAGATE_EXCEPTIONS'] = True
app.logger.setLevel('ERROR')
from database import *
migrate = Migrate(app,db)
engine = create_engine('sqlite:///db', echo=False)
if __name__ == '__main__' :
# this code uses to drop alembic_version, to avoid error 'Can't locate revision identified by'
#sql = 'DROP TABLE IF EXISTS alembic_version ;'
#result = engine.execute(sql)
#this code uses to drop all logs
# u = Logs.query.delete()
# db.session.commit()
# u = Logs.query.all()
u = User.query.filter(User.name==')
for r in u :
print(r)