1

I have a Digi ConnectPort X4 here and I am going to run a simple web server on it to serve the information from the ZigBee network that is attached.

The HTTPBaseServer and subclasses are pure Python classes, but I also want to have some kind of database running on the device. As I don't need to have complex functionality, I thought I would try to get PySQLite running on this embedded box.

However, as it turns out, I cannot use GCC on this box, so is there any other possibiliy to get some kind of database functionality on this box? Or did I miss a possibility to get that SQLite adapter on this box?

Joost
  • 536
  • 4
  • 16

2 Answers2

2

I am in the same situation as you. You can make yourself a pseudo DB with some tuples, or in my case some dictionarys. Something like that:

pseudoDB={}

pseudoDB[1]={'id':1, 'zb-dev-object':ZB_object, 'power':power_value} #and so on

  • I was keeping that in another python file (.py) (pringing it just like a dictionary) and in some time when my ConnectPort X4 get restarted, that file is imported like module. This means you have to care for any INSERT, UPDATE, DELETE in DB terms. – Nikolai Jivkov Jul 25 '12 at 13:36
  • I've ended up doing something similar, but I can derive the column information just from the index as that works more efficiently. Eventually, I just took my losses and did not write all values to disk directly, just every two minutes or so. File I/O has a lot of overhead. As for reading data; that's still very slow, but isn't done so often, could be easily improved although that would require another custom solution. – Joost Jul 25 '12 at 18:07
2

Someone must have had a compiler to make Python. A compiler is required to get (py)sqlite working.

You may be able to use the db/anydbm module instead which will use a flavour of dbm or a pure Python alternative. This won't give you a SQL database, but will give you a key value store which is likely good enough for your needs.

Roger Binns
  • 3,203
  • 1
  • 24
  • 33
  • Yes, I can ask the manufacturer if it is possible to compile code for this specific box; however I think they may want to protect intellectual property. I want to be able to store tuples of consisting of a timestamp, ZigBee Device Object ID, and some reals (power, current, THD, voltage etc). The key-value system feels like a simple array to me. Although this can be very powerful for simple applications, my application may need to store 104.000 records/tuples for a single device when > 50 devices may be needed in the future. – Joost Oct 05 '11 at 08:22
  • I see that there is the Shelve class which uses the anydb system with Marshal or Pickle to serialize the data to a string. However, this means my overhead my become quite large. Another thing is that Shelve also is not available 'out-of-the-box'... – Joost Oct 05 '11 at 10:11
  • Shelve is however fully Python and therefore I was able to run the shelf example. I think I may be able to work with this for the moment! Thank you! – Joost Oct 05 '11 at 11:45