python an sqlite objects

azrael jura.grozni at gmail.com
Wed Dec 3 14:11:19 EST 2008


It logical that it would be more efficient and logical to use a object
oriented database, but in this case I ask because of the portable
nature of sqlite.

so, if I get it right, this should be possible

>>> class a:
>>>   def __init__(self, a, b):
>>>     self.c = a+b
>>>     self.d = a*b
>>>
>>> ob = a(1,3)
>>> oc = a(2,4)
>>> dbCursor.execute("insert into tabel example values (?,?)",[ob, oc]) #table example consists of blob atributes
>>> dbcursor.commit()

>>> dbCursor.execute("select * from table example")
>>> list = dbcursor.fetchall()
>>> for i in list:
>>>   print i.c, i.d
>>>
4 3
6 6




More information about the Python-list mailing list