Reputation: 149
I'm a rookie at SQLite stuff, and a relative noob in Python. I'm collecting process instrument data for a demonstration application. I've written this code:
from DAQ_Util import *
from sqlite3 import *
print 'Setting up memory-resident SQL database...'
BenchDB = connect(':memory:')
DBTableSetup = BenchDB.cursor()
DBTableSetup.execute("create table ss2000 (timestamp, var1, var2, var3, var4, var5, var6, var7, var8, var9)")
DBTableSetup.close()
# Access data from SS2000 TDL Sensor
instReading = ss2000serialRead('192.168.1.121', 4001, 57)
print instReading
SS2000TabPopulate = BenchDB.cursor()
SS2000TabPopulate.execute("insert into ss2000 values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
[instReading(i) for i in instReading])
print '...Done'
The DAQ_Util module is a collection of routines for grabbing process data from instruments. ss2000serialRead
is from DAQ_Util and brings in a list of data strings from such an instrument. Some data is reproduced below. All I'm trying to do is write this data to an sqlite
table using a list comprehension. It's not working, and I don't know how to interpret the error msg, though I think folks who know more about Python then me may spot the error immediately, or so I hope... :o) A dump of the screen output follows:
$ python SQLite-test.py
Setting up memory-resident SQL database...
Try connecting to serial server...
['2012-08-05 16:52:49.548095', '20.0000', '0.0000', '13.5', '76.60', '8190', '1640', '240', '-13', '79.40']
Traceback (most recent call last):
File "SQLite-test.py", line 17, in <module>
[instReading(i) for i in instReading])
TypeError: 'list' object is not callable
$
Can someone please point out the error? Thanks!
Thanks Ignacio, here's corrected code:
# Access data from SS2000 TDL Sensor
instReading = ss2000serialRead('192.168.1.121', 4001, 57)
print instReading
SS2000TabPopulate = BenchDB.cursor()
SS2000TabPopulate.execute("insert into ss2000 values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
instReading)
==== Red
Upvotes: 0
Views: 660
Reputation: 799062
instReading
is already a sequence.
....execute(..., instReading)
Upvotes: 3