Re: Error Binding Parameter 0

Adrian Klaver <[email protected]>
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <[email protected]>
On Wednesday 20 December 2006 6:59 pm, Rich Shepard wrote:
> On Wed, 20 Dec 2006, Adrian Klaver wrote:
> > The problem is that triple quoting leads to a stmt1 string passed to
> > cur.execute of:
> >
> > "insert into variable (var_name, var_desc, policy_name, sub_policy_name)
> > values (?,?,?,?),(varDlg().varName, varDlg().varDesc,
> > varDlg().polName,varDlg().subName) "
> >                                    ^ quote
> > when what you want is:
> >
> > "insert into variable (var_name, var_desc, policy_name,
> > sub_policy_name) values (?,?,?,?)",(varDlg().varName, varDlg().varDesc,
> > varDlg().polName,varDlg().subName)
> >                                   ^ no quote
>
> Adrian,
>
>    Sonofagun! I didn't pick up on this from the trac page or my other
> reading.
>
> > To do this you need to have stmt1 be:
> >
> > "insert into variable (var_name, var_desc, policy_name, sub_policy_name)
> > values (?,?,?,?)"
> >
> > and your execute be:
> >
> > cur.execute(stmt1,(varDlg().varName, varDlg().varDesc,
> > varDlg().polName,varDlg().subName)
>
>    You have an open parenthesis at the beginning of stmt1. I closed it so
> my file looks like this:
>
>     stmt1 = """insert into variable(var_name, var_desc, policy_name,
> sub_policy_name) values (?,?,?,?)"""
>     self.appData.cur.execute(stmt1,(varDlg().varName, varDlg().varDesc,
> varDlg().polName, varDlg().subName))
>
> but, I'm still getting this same error message:
>
>    File "/data1/eikos/variablePage.py", line 237, in OnVarAdd
>      self.appData.cur.execute(stmt1,(varDlg().varName, varDlg().varDesc,
> varDlg().polName, varDlg().subName))
> pysqlite2.dbapi2.InterfaceError: Error binding parameter 0 - probably
> unsupported type.
>
>    Quite frustrating. I've spent several hours searching with Google,
> reading the pysqlite trac doc page, and trying various expressions. All
> generate one python error or another. Sigh.
>
>    Is there a better way of writing this insert statement so the four
> variables from the dialog box in class varDlg() are inserted as a single
> row in the table variable? I think I'll go make dinner now and come back to
> this tomorrow morning.
>
> Many thanks,
>
> Rich
My next suggestion would to see if the varDlg() functions are really returning 
what you want. Sprinkle some print statements i.e print varDlg().varName to 
see if you are getting the varName. Also in the OnVarAdd function you assign 
varDlg() to newVar,you might want to use the assigned name i.e. 
newVar.varName. I don't know how the rest of the module is set up but the 
newVar assignment may be masking varDlg()
-- 
Adrian Klaver
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.