Re: Error Binding Parameter 0
Rich Shepard <[email protected]>
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
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
--
Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc.(TM) | Accelerator
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863