Ensuring Text Is Quoted On Insertion
Rich Shepard <[email protected]>
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
In my application I have statements such as this one:
insertStatement = "insert into rules (policy_name, subpolicy_name, \
rule_num, rule_string) values (?,?,?,?)"
where the four values are all text. However, three of the four may be
multiword strings, and I want to have them quoted so they are treated as a
single field for insertion into the database table.
If I quote the question mark, then that's what is inserted. Similarly, if
I try printing the variable names quoted, they get printed rather than the
values. I've tried using str(varName), but that does nothing. I'm stuck ...
and I can't get up.
Here's an example: I entered the following for the four variables above:
wetlands
quantity
qn1
if size is large, then value is increased
With a print statement -- print str(pName), str(sName), str(rNo), str(rTxt)
-- before the insertStatement I see this:
wetland quantity wn1 if size is large, then value is increased
In other words, there is nothing to separate each field. How do I put
(single) quotes around each field so pysqlite puts an entire field into the
database table, rather than only the first four space-delineated strings?
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