문제

I have the following code which should delete the first row in my database but it returns the above error sqlite3.operationalError: No Such Table: updates - what have I done wrong?

source = os.path.expanduser(r'~\AppData\Roaming\aprogram\source.db')

def clear_cache():
    conn = lite.connect("source")
    cursor = conn.cursor()

    sql = """DELETE FROM updates
    WHERE _id = '1'
    """

    cursor.execute(sql)
    conn.commit()
    conn.close()
    return;

clear_cache();
도움이 되었습니까?

해결책

Look carefully at line 4:

conn = lite.connect("source")

"source" means finding the db file under current directory, I think conn = lite.connect(source) is what you want.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top