Tie dictionary to database table?

Peter Otten __peter__ at web.de
Fri Jun 10 08:25:22 EDT 2016

Peter Heitzer wrote:

> Christian Gollwitzer <auriocus at gmx.de> wrote:
>>Am 10.06.16 um 09:30 schrieb Peter Heitzer:
>>> Michael Selik <michael.selik at gmail.com> wrote:
>>>> An ORM might be overkill. If you just want a persistent dictionary,
>>>> just use the shelve module.
>>>> https://docs.python.org/3/library/shelve.html
>>> That looks like tie in Perl. Unfortunately I have to use mysql as
>>> database and I need concurrent read/write as the table may be modified
>>> by other processes.
>>> Meanwhile I have analized my demans a bit and modified the task so that
>>> I need not read values but rather make updates to the tables.
>>It wouldn't be that difficult to roll your own thing which does that;
>>you just need to define __setitem__ and __getitem__ in your class which
>>translates between the SQL call and the Python code.
> That's a good idea.

There's an old recipe for sqlite3


that you might adapt.

More information about the Python-list mailing list