Python Forum
SQLite NO column exists - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: SQLite NO column exists (/thread-5913.html)



SQLite NO column exists - rachitmishra25 - Oct-27-2017

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



RE: SQLite NO column exists - Larz60+ - Oct-27-2017

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.