
AUTO SCRIPT WRITER 2 LARRY KEYS WINDOWS
You can also eliminate all the local variables in the method read_waiting and refer the instance values ( self.table_name, etc) directly. If you're running a version of Windows that includes PowerShell 2.0 (Windows XP with Service Pack 3, Windows Vista with Service Pack 1, Windows 7, etc.) you can use Windows Scripting Host as a COM object from your PS script or use VB's Intereact class. This is because 1) if the value comes from user input SQL injection is possible and 2) it won't work if the value itself contains a single quote (as in the last name O'Malley, for instance). Note that the value your supplying should not be placed in the string by formatting (as your doing) but should be represented by a parameter and passed separately into execute.

Because table Test_Task does not contain a column named Waiting, SQLite is not able to interpret the SQL and produces the error you are seeing. This second piece of SQL is searching for records where the columns status and Waiting have identical values. The correct SQL to search for records where the column status contains the word Waiting is: SELECT Task_ID FROM Test_Task WHERE status = 'Waiting'īut what you are generating is: SELECT Task_ID FROM Test_Task WHERE status = Waiting Your version causes SQL to look for the contents of a column named Waiting and compare that, not the string 'Waiting'. You want it to contains WHERE status = 'Waiting' (notice the single quotes around the text string). If you format your SQL and print it out you will quickly see that it contains WHERE status = Waiting. My sqlite3 db schema and data stored on the db is as follows:ĭata stored on the DB: sqlite> SELECT * from suggest how can achieve this. Sqlite3.OperationalError: no such column: Waiting. I am getting the following error : python class.pyįile "class.py", line 26, in read_waiting #!/usr/bin/pythonĭef _init_(self,db_name,table_name,status,column_to_read,column_state):Ĭ.execute("SELECT (".\įormat(coi=column_2, tn=table_name, cn=column_3,cs=column_state))Ĭ = Read_class('test.db', 'Test_Task', 'status', 'Task_ID','Waiting') I have written a script like this with class, but it failing.

I want to pass column names, table_name and condition check value as variables. I am trying to SELECT value of column_2 from the sqlite3 TABLE table_name WHERE, column_3 value is 'Waiting'.
