0

I have created a sqlite database on this directory 'C:\sqlite\db' and I want to delete record where id = 2 (as an example) but when I run code I get 'no such tale error'.

I have checked with command line for the table on the same directory and find the table and database on the same directory with data in tables.

what would be the error in my code. it does it have any problem with directory setting?

import sqlite3
con = sqlite3.connect('C:\\sqlite\db\pythonsqlite')

sql = 'DELETE FROM FIRST WHERE id = ?'
cur = con.cursor()
cur.execute(sql, (1,))
M.Sadek
  • 1
  • 3
  • 1
    Are you sure that's the correct filename? It doesn't end in `.db` or `.sqlite` or something similar? – John Gordon Oct 31 '17 at 02:48
  • I have tried it again as 'C:\\sqlite\db\pythonsqlite.db' but it give the same error. when I connect to the data base it does not give error. error appears when I try to delete the row. – M.Sadek Oct 31 '17 at 02:54
  • Does the database actually exist? Have you imported your schema into the database? – Carey Oct 31 '17 at 03:00
  • yes I have checked it with command line and sqlite studio and found the table in both with data. – M.Sadek Oct 31 '17 at 03:03
  • _I have tried it again as 'C:\\sqlite\db\pythonsqlite.db'_ This comment makes me think that you aren't certain what the database filename is. Do you know the exact filename, or not? – John Gordon Oct 31 '17 at 03:08
  • Try to print out to check what's the tables inside: `print(cur.execute("SELECT name FROM sqlite_master WHERE type='table'").fetchall())` – Tiny.D Oct 31 '17 at 03:09

0 Answers0