Python Forum
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SQLite NO column exists
#1
I am trying to insert values into a SQLite DB integrated with Python. I have done that successsfully for most of the tables with an exception of one which has a column name: TOB-2/-2a_Measure_Desc

This snippet shows the fragment where I am making the insertions
                        index = "%s__%s" % (tablename, col)
                        sql_query = "CREATE INDEX %s on %s (%s)" % (index, tablename, col)
                        cursor.execute(sql_query)
                    print(tablename)
                    #print(error)
                insert_values = "INSERT INTO %s VALUES (%s)" % (tablename, ", ".join([ "?" for col in row ]))
Error:
Traceback (most recent call last): File "C:\Users\Rachit-PC\AppData\Local\Continuum\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2881, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "<ipython-input-50-024cf4abddf6>", line 60, in <module> cursor.execute(sql_query) sqlite3.OperationalError: no such column: tob_2__2a_measure_desc
Reply
#2
you can do the following:
  • from a command or terminal window, where your database is located,
        type: sqlite3 dbname
  • This will get you into interactive mode.
  • type: 'schema tablename;'
  • this will list the columns for the table in question.
  • check spelling, etc.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  python sqlite autoincrement in primary column janeik 6 1,211 Aug-13-2023, 11:22 AM
Last Post: janeik
  p]Why os.path.exists("abc/d") and os.path.exists("abc/D") treat same rajeev1729 1 2,201 May-27-2020, 08:34 AM
Last Post: DeaD_EyE
  SQLite Query multiple column search whacky7 6 8,456 Apr-01-2019, 09:29 PM
Last Post: whacky7

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020