python - What is wrong with my string format? (Even WITH the trailing comma in the parameter) -
first tried:
sqlite3.cursor.execute("select * mytable mycol=?", (myval,))
when execute in shell works. in class method tells me: programmingerror: incorrect number of bindings supplied. current statement uses 0, , there 12 supplied.
then tried:
sqlite3.cursor.execute("select * mytable mycol='%s'" % myval)
when execute in shell works. in class method tells me: programmingerror: incorrect number of bindings supplied. current statement uses 0, , there 12 supplied.
so decided format string first , pass in. this:
sqlcmd = "select * mytable mycol='%s'" % myval
when execute in shell works. in class method tells me same error: programmingerror: incorrect number of bindings supplied. current statement uses 0, , there 12 supplied.
my method defined this:
def mymethod(self, myval): cur = self.conn.cursor() cur.execute( "..." ... ) ....
what missing?
this "know tools" problem. mentioned above in comment, issue not understanding when/how pycharm reloads modified code. testing class in python console in pycharm. after changed code not automatically reload python code, runs cached code.
but part threw me off when reports error, pulls source code line current source code, not cached code. first time through forgot trailing command ...(myval,). when got error realized mistake , added it. reran , displayed same error, pulled source code in error modified code. not cached code being executed.
i ran on command line , worked (as expected). not realizing needed reload python console when made code change.
Comments
Post a Comment