Domanda

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();
È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top