0
0 комментариев

Как заменить еденицы на переменные?

def inf(fn, name, price):
    import sqlite3
    from datetime import datetime
    dat, price, name = str(datetime.now())[0:19], int(price.replace(' ', '')), name.replace('"', '"').replace('"', '"').replace('&','&')
    log = open('log.txt','a')
    conn = sqlite3.connect('pmonitor.db')
    c = conn.cursor()
    c.execute("SELECT COUNT(*) FROM names2 WHERE name = '1'")
    if c.fetchall() != [(0,)]:
        c.execute("INSERT INTO prices VALUES(?,?,?,?)", (fn, dat, name, price))
    else:
        c.execute("SELECT COUNT(*) FROM names1 WHERE name = '1'")
        if c.fetchall() != [(0,)]:
            c.execute("INSERT INTO prices VALUES(?,?,?,?)", (fn, dat, name, price))
        else:
            c.execute("SELECT COUNT(*) FROM stopnames WHERE name = '1'")
            if c.fetchall() == [(0,)]:
                log.write(name+'\t')
    conn.commit()
    log.close()


Добавить комментарий