[ZODB-Dev] Relstorage Database Adapter
Santi Camps
scamps at earcon.com
Thu Nov 25 09:49:06 EST 2010
On Wed, Nov 24, 2010 at 7:24 PM, Shane Hathaway <shane at hathawaymix.org>wrote:
> On 11/24/2010 05:17 AM, Santi Camps wrote:
>
>> Hi all
>>
>> I'm using relstorage for a long time with very good results. Until
>> know, I also use database adapters like ZPsycopgDA to connect the same
>> SQL database and store information in other application tables. I was
>> thinking to create a Relstorage Database Adapter able to do the work
>> using relstorage configuration and connections. Some preliminary
>> simple tests seems to work:
>>
>> def execute_query(conn, cursor, *args, **kw):
>> query = kw['query']
>> cursor.execute(query);
>> return cursor
>> query = 'SELECT COUNT(*) FROM kmkey_task'
>> rows = app._p_jar._storage._with_store(execute_query, query=query)
>> print rows.fetchone()
>>
>>
>> The question is, can I go on ? Or use same connections than relstorage
>> could cause problems at ZODB level ?
>>
>
> Well, it doesn't look like you're using the two RelStorage connections the
> way they are intended to be used. For the code snippet you gave, it's
> likely that you want to use the load connection rather than the store
> connection.
>
> The load connection ensures consistent reads. RelStorage does a number of
> things to maintain that guarantee. The load connection is never committed,
> only rolled back.
>
> The store connection is intended to be used only during transaction commit.
> At the beginning of a commit (tpc_begin), RelStorage rolls back the store
> connection in order to get the most recent updates. The store connection
> and load connection are often out of sync with each other, so code that uses
> the store connection should detect and handle conflicting updates.
>
> I suspect the load/store connection split is too complicated for most apps
> that just want to interact with the database, so I haven't exposed any
> documented API. I considered making an API when I worked on
> repoze.pgtextindex, but I concluded that pgtextindex can be a bit lazy about
> consistency and therefore doesn't need all the extra complexity that reusing
> RelStorage connections would bring.
>
>
I understand it. I will try to do it simpler: create new connections
using relstorage connection string
Thanks a lot for your explanation.
--
Santi Camps
KMKey hacker (http://www.kmkey.com)
Earcon S.L. (http://www.earcon.com)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zodb-dev/attachments/20101125/2e4b05c9/attachment.html
More information about the ZODB-Dev
mailing list