Reading data from SQLite with btmon

Post any 3rd party software here.
Post Reply
JWHardesty
Posts: 27
Joined: Mon Jun 07, 2010 1:12 pm

Reading data from SQLite with btmon

Post by JWHardesty » Thu Jul 03, 2014 6:45 pm

Btmon needs the database name and table information. What is the table name?

I have the source setup like this

[source]
device_type = ecm1240
sqlite_read = true
sqlite_src_file = \Brultech\Database\ecm1.db3
sqlite_src_table= ecm

but I get this error

D:\btmon>btmon.py -c sqlToSEG.cfg --debug --print
2014/07/03 18:42:37 btmon: 3.0.7
2014/07/03 18:42:37 python: 2.7.7 (default, Jun 1 2014, 14:21:57) [MSC v.1500 64 bit (AMD64)]
2014/07/03 18:42:37 platform: win32
2014/07/03 18:42:37 device type: ecm1240
2014/07/03 18:42:37 device list: ['fc']
2014/07/03 18:42:37 packet format: ecm1240bin
2014/07/03 18:42:37 schema: counters
2014/07/03 18:42:37 buffer size: 120
2014/07/03 18:42:37 DB: polling interval: 60 seconds
2014/07/03 18:42:37 DB: table: \Brultech\Database\ecm1.db3
2014/07/03 18:42:37 SQLITE: file: ecm
2014/07/03 18:42:37 SEG: upload period: 45
2014/07/03 18:42:37 SEG: url: http://api.smartenergygroups.com/api_sites/stream
2014/07/03 18:42:37 SEG: token: 570681f49b96bce
2014/07/03 18:42:37 SEG: map:
2014/07/03 18:42:37 packet format is ECM1240BinaryPacket
2014/07/03 18:42:37 using collector SqliteCollector
2014/07/03 18:42:37 using 2 processors:
2014/07/03 18:42:37 PrintProcessor
2014/07/03 18:42:37 SmartEnergyGroupsProcessor
2014/07/03 18:42:37 setup SqliteCollector
2014/07/03 18:42:37 unrecognized token: "\"
Traceback (most recent call last):
File "D:\btmon\btmon.py", line 1995, in run
self.packet_collector.setup()
File "D:\btmon\btmon.py", line 2429, in setup
super(SqliteCollector, self).setup()
File "D:\btmon\btmon.py", line 2349, in setup
cursor.execute('select max(time_created) from ' + self._table)
OperationalError: unrecognized token: "\"
2014/07/03 18:42:37 cleanup PrintProcessor
2014/07/03 18:42:37 cleanup SmartEnergyGroupsProcessor
2014/07/03 18:42:37 cleanup SqliteCollector
2014/07/03 18:42:37 DB: closing database connection

It has the table and filename in the wrong places.
Jonathan
sandeen
Posts: 41
Joined: Fri Jan 10, 2014 3:33 pm

Re: Reading data from SQLite with btmon

Post by sandeen » Tue Jul 08, 2014 2:11 pm

Yep, you're right, it calls:

Code: Select all

        col = SqliteCollector(options.sqlite_src_file or DB_FILENAME,
                              options.sqlite_src_table or dbtable,
                              options.sqlite_poll_interval or DB_POLL_INTERVAL)
but that function looks like:

Code: Select all

class SqliteCollector(DatabaseCollector):
    def __init__(self, table, filename, poll_interval):
so table & filename are indeed reversed.

Does it work if you flip either the call or the definition, so that they match? i.e change it to:

Code: Select all

class SqliteCollector(DatabaseCollector):
    def __init__(self, filename, table,poll_interval):
I'm still not sure if it'll like the DOS backslashes, but the above should be a start.
Post Reply