This can be done using bb.persist_data module that uses sqlite via pyslite2.

+

+

<pre>

+

#!/usr/bin/env python

+

# ex:ts=4:sw=4:sts=4:et

+

# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-

+

+

import bb, os, sys

+

from bb import data, persist_data, fetch

+

+

__version__ = "0.0.1"

+

+

def main():

+

"""

+

The main Method

+

"""

+

+

# persist_data module need debug_level to be set

+

bb.msg.set_debug_level(0)

+

+

# init a data with PERSISTENT_DIR to set where the data will be saved

+

d = data.init()

+

data.setVar('PERSISTENT_DIR', os.getcwd(), d)

+

+

# create persist_data base in bb_persist_data.sqlite3

+

pd = persist_data.PersistData(d)

+

+

# create a sql table

+

pd.addDomain("MYBASE")

+

+

# add a data in this table

+

pd.setValue( "MYBASE", "TOTO", "hello world!")

+

+

# print it

+

val = pd.getValue ( "MYBASE", "TOTO")

+

print val

+

+

if __name__ == '__main__':

+

main()

+

</pre>

+

+

You can edit and watch your base using [http://sqlitebrowser.sourceforge.net sqlitebrowser] for example. Should be useful for debug and test purpose. You can look also at fetch module source that use bb.persist_data.