예제 #1
0
def autoquery():
    with mss.mss() as sct:
        # print(sct.shot())
        beg = time.time()
        monitor = {"top": 140, "left": 100, "width": 270, "height": 73}
        # 指定截图的范围
        # output = "sct-{top}x{left}_{width}x{height}.png".format(**monitor)
        output = "problem.png"
        # Grab the data
        sct_img = sct.grab(monitor)
        # Save to the picture file
        # 转成PNG格式保存
        mss.tools.to_png(sct_img.rgb, sct_img.size, output=output)
    keyword = image2text('problem.png')
    print('題目:' + keyword)
    url = "http://www.baidu.com/s?wd=" + keyword
    webbrowser.open(url, new=0, autoraise=True)
    end = time.time()
    print('耗時:' + str(end - beg))
    insert_sql = """
                insert history (question , time)
                values('%s' , %s);
                """
    insert_sql = insert_sql % (keyword, end - beg)
    db.insert_or_update_data(insert_sql)
예제 #2
0
def do_add_user():
    print(request.form)
    name = request.form.get("name")
    sex = request.form.get("sex")
    age = request.form.get("age")
    email = request.form.get("email")
    sql = f"""
        insert into user (name, sex, age, email)
        values ('{name}', '{sex}', {age}, '{email}')
    """
    print(sql)
    db.insert_or_update_data(sql)
    return "success"
예제 #3
0
import db

query_sql = "select * from user"
data = db.query_data(query_sql)

for i in data:
    print(i)

insert_sql = """
    insert user (name,sex,age,email)
    values ('mayi','man',20,'*****@*****.**')
"""
db.insert_or_update_data(insert_sql)

query_sql = "select * from user"
data = db.query_data(query_sql)

for i in data:
    print(i)

update_sql = "update user set name='damayi' where id=3"
db.insert_or_update_data(update_sql)

query_sql = "select * from user"
data = db.query_data(query_sql)

for i in data:
    print(i)