| Newsgroups |
gmane.comp.python.db.pysqlite.user |
| Message-ID |
<OFF1CB1B98.198CC970-ON852571E8.006D54E4-852571E8.006D6A05@bankofny.com> |
From what I can tell nothing, I would be double checking your data, such
as the length of values or chunk, as that may be the problem.
Thanks,
Greg Givler
Information Technology
Lockwood®
10 Valley Stream Parkway
Malvern, PA 19355
Phone: (484) 605-4826
Email: [email protected]
Rich Shepard
<rshepard@appl-ecosys To: [email protected]
.com> cc:
Sent by: Subject: [pysqlite] Do Not See My Error
pysqlite-bounces@list
s.initd.org
09/13/2006 02:42 PM
Please respond to
Rich Shepard; Please
respond to "For users
of the pysqlite
database module."
I'm testing my application interactively using the pycrust shell. In
the
application the data will come over a serial line from a OMR card
reader.
For testing purposes (until I receive the scanner), I set up a test set
of
data that looks like this:
"nat", "pro", 2, 2, 7, 3, 7, 9, 3, 6, 5, 3, 4, 5, 7, 8, 2, 6, 3, 7, 5,
1, 1,
2, 1, 9, 2, 5, 5, 4
There are 180 lines of data in the sample file.
I'm not reading or transforming those data correctly so they can be
inserted into a sqlite3 table. I'd greatly appreciate learning how to do
it
properly. The code to be tested is:
PyCrust 0.9.5 - The Flakiest Python Shell
Python 2.4.1 (#1, Apr 20 2005, 11:40:53) [GCC 3.3.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>> from pysqlite2 import dbapi2 as sqlite3
>>> con = sqlite3.connect(":memory:")
>>> cur = con.cursor()
>>> cur.execute("CREATE TABLE voting (vote_id INTEGER PRIMARY KEY
>>> AUTOINCREMENT, \
cat TEXT, pos TEXT, pr1 REAL, pr2 REAL, \
pr3 REAL, pr4 REAL, pr5 REAL, pr6 REAL, \
pr7 REAL, pr8 REAL, pr9 REAL, pr10 REAL, \
pr11 REAL, pr12 REAL, pr13 REAL, \
pr14 REAL, pr15 REAL, pr16 REAL, \
pr17 REAL, pr18 REAL, pr19 REAL, \
pr20 REAL, pr21 REAL, pr22 REAL, \
pr23 REAL, pr24 REAL, pr25 REAL, \
pr26 REAL, pr27 REAL, pr28 REAL)")
<pysqlite2.dbapi2.Cursor object at 0x41d117d0>
>>> fh = file('/data1/eikos/sample.dat', 'r')
>>> while True:
... line = fh.readline()
... values = []
... chunk = line.split(',')
... values = chunk
... cur.execute("insert into voting(cat, pos, pr1, pr2, pr3, pr4, \
pr5, pr6, pr7, pr8, pr9, pr10, pr11, pr12, pr13, pr14,
pr15, \
pr16, pr17, pr18, pr19, pr20, pr21, pr22, pr23, pr24,
pr25, \
pr26, pr27, pr28) values
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, \
?,?,?,?,?,?,?,?,?,?,?,?,?)",values)
At this point I get "ProgrammingError: Incorrect number of bindings
supplied. The current statement uses 30 and there are 1 supplied."
What have I done incorrectly here?
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
_______________________________________________
pysqlite mailing list
pysqlite-IAPFreCvJWPBWskQ1e/[email protected]
http://lists.initd.org/mailman/listinfo/pysqlite
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please call the help desk at ext 4850
______________________________________________________________________
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________