[ZODB-Dev] A different sort of ZODB backend

Itamar Shtull-Trauring itamar@itamarst.org
Wed, 20 Nov 2002 11:50:06 -0500


On Wed, 20 Nov 2002 08:40:42 -0500
Greg Ward <gward@mems-exchange.org> wrote:

> It looks like a fairly sensible/obvious way to map Python objects onto
> SQL.  Some questions:
> 
>   * how are dictionary keys handled?  is that what attributeType and
>     attribute are?  if your dicts table can handle arbitrary dicts,
>     I think those columns are misnamed

Actually, I should call the columns keyType, key, valueType, value.
For {"bar" : 1} keyType would be "str", key would be "bar", valueType
would be "int" and value would be "1".

>   * it might be a useful optimization to have a table for dicts with
>     string keys, ie instance dicts.  That's obviously a very common
>     sort of dict in a graph of Python objects, so probably worth
>     optimizing.  (OTOH, premature optimization is the root of all
>     evil...) 

I was thinking of doing that, yes.

>   * what precisely do you put in the 'attribute' and 'value' columns?
>     eg. is the Python integer 1 stored as an SQL integer, or as
>     the SQL string '1', or what?

PySQLite is typeless, everything is stored as strings. So in all cases
you'd be storing a string, and you'd know what to convert it to based on
the type.

-- 
Itamar Shtull-Trauring    http://itamarst.org/
Available for Python, Twisted, Zope and Java consulting
***> http://VoteNoWar.org -- vote/donate/volunteer <***