Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Peter Otten <__peter__@web.de> Newsgroups: comp.lang.python Subject: Re: Tie dictionary to database table? Date: Fri, 10 Jun 2016 14:25:22 +0200 Organization: None Lines: 25 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Trace: news.uni-berlin.de 2FTLkfm6dJIBzErx3LAaRQrvlAfMOYH01+hOTNIvI8Wg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'modified': 0.05; 'concurrent': 0.09; 'orm': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.10; 'dictionary,': 0.16; 'meanwhile': 0.16; 'perl.': 0.16; 'processes.': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'received:t-ipconnect.de': 0.16; 'recipe': 0.16; 'sqlite3': 0.16; 'wrote:': 0.16; "wouldn't": 0.16; '>>>': 0.20; 'code.': 0.23; 'bit': 0.23; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'define': 0.27; 'module.': 0.27; 'values': 0.28; 'looks': 0.29; 'url:activestate': 0.29; 'task': 0.30; 'table': 0.32; 'class': 0.33; 'url:python': 0.33; 'michael': 0.33; 'url:code': 0.34; 'but': 0.36; 'url:org': 0.36; 'url:library': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'christian': 0.38; 'does': 0.39; 'rather': 0.39; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'url:3': 0.60; 'your': 0.60; 'skip:u 10': 0.61; 'between': 0.65; 'gollwitzer': 0.84; 'tie': 0.84; 'url:recipes': 0.84 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: p57bd95f3.dip0.t-ipconnect.de User-Agent: KNode/4.13.3 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: Xref: csiph.com comp.lang.python:109781 Peter Heitzer wrote: > Christian Gollwitzer wrote: >>Am 10.06.16 um 09:30 schrieb Peter Heitzer: >>> Michael Selik 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 http://code.activestate.com/recipes/576638-draft-for-an-sqlite3-based-dbm/ that you might adapt.