RE: [sqlalchemy] Storing Nested Lists

2010-04-26 Thread King Simon-NFHD78
 -Original Message-
 From: sqlalchemy@googlegroups.com 
 [mailto:sqlalch...@googlegroups.com] On Behalf Of greg
 Sent: 25 April 2010 22:59
 To: sqlalchemy
 Subject: [sqlalchemy] Storing Nested Lists
 
 Hi All,
 
 I'm new to sqlalchemy.  I've been reading the documentation and group
 archives, but can't really find an answer to my question.  I suspect
 it's a question of terminology, and that I don't really know the term
 for what I'm looking for.
 Can I map a nested list to one column, and have my nested list
 returned to me intact?  A simple example is a list like:
 
 ['a','b','c', ['x','y','z',['m','n','o']]]
 
 If anyone can point me in the right direction, I'd much appreciate it.
 Thanks.
 

If you make the column a PickleType:

 
http://www.sqlalchemy.org/docs/reference/sqlalchemy/types.html#sqlalchem
y.types.PickleType

...it should behave as you want.

Simon

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Mapping dictionaries with string keys and record values

2010-04-26 Thread Torsten Landschoff
Hi Michael.

On Sun, 2010-04-25 at 22:32 -0400, Michael Bayer wrote:

   You should be able to roll this yourself as a custom dictlike
   collection class . 

That's what I did :-) I wrote mostly to share my code and to suggest
that this should be available out of the box.

  sorry, it seems you've done that already.  I'm surprised the
  existing attribute_mapped_collection doesn't do this already ?

I was surprised as well.

 well, it doesn't.  It should, and maybe should raise an error if the
 two values don't match.  It doesn't make much sense to add another
 collection class to do what the first one should.

Agreed.

 I'm sure you noticed that you can remove the repetition by working the
 other way, i.e.:
 
 item.note.set(Note(key=color, value=blue, desc=This should be
 blue because))
 item.note.set(Note(key=shape, value=rectangular))

Indeed, although I find it unintuitive that set actually does an
append/insert/add operation. Apart from that, I try to keep the mapping
code and the data objects (which carry application logic) separate in
case we ever want to use a non-SQL data backend (NoSQL DB, ZODB, ...).
So usually, there is no set method on item.notes and there is no key
property in the Note class (it's added by the mapper as _key).

 also, never do this:

 
 class Note(object):
 def __init__(self, **args): 
 self.__dict__.update(args)

That's not production code. I just added it to get initialization in one
line.

 you bypass all of SQLAlchemy's history tracking logic.  do this
 instead:
 
 
 class Note(object):
 def __init__(self, **args): 
 for k, v in args.items():
 setattr(self, k, v)

I usually name the possible keyword arguments explicitly as the output
of help(Note) is otherwise quite unhelpful.

Thanks for your reply and the remarks! Do you plan to extend
attribute_mapped_collection to update the key like in my example?

Be aware that this approach also has it's downside. For example,
assigning 

item2 = Item()
item2.notes['color'] = item.notes['color']

will not work contrary to what one might expect (it generated a conflict
on the id column). The solution is to have the target collection copy
the assigned object if it has a key already. But that might be too much
magic to be easy to understand.

So I think, the automatic key update should be an option.

Greetings, Torsten

-- 
DYNAmore Gesellschaft fuer Ingenieurdienstleistungen mbH
Torsten Landschoff

Office Dresden
Tel: +49-(0)351-4519587
Fax: +49-(0)351-4519561

mailto:torsten.landsch...@dynamore.de
http://www.dynamore.de

Registration court: Mannheim, HRB: 109659, based in Karlsruhe,
Managing director:  Prof. Dr. K. Schweizerhof, Dipl.-Math. U. Franz

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Re: Storing Nested Lists

2010-04-26 Thread greg
Excellent.  Thanks very much.

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] further restricting a query provided as raw sql

2010-04-26 Thread Chris Withers

Michael Bayer wrote:

Any serious ideas or should I just go sulk in the corner?


you have to use IN, and you have to generate the SQL every time based on the 
number of values you'd like to put into the IN.


Does SA have any helper code anywhere for this?

Chris

--
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] correct way to handle 'MySQL server has gone away'?

2010-04-26 Thread Chris Withers

Chris Withers wrote:
raise exc.InvalidRequestError(Can't reconnect until invalid 
transaction is rolled back)
sqlalchemy.exc.InvalidRequestError: Can't reconnect until invalid 
transaction is rolled back


Asking here as it sounds like it might be related.
It occurred transiently, though, and appears to have resolved itself 
without any intervention. Where would I look to find out what caused the 
invalid transaction and how it was rolled back?


We've had this occur again, wondered if anyone had any suggestions...

So, the first error is this:

return session.query(Feed).filter(Feed.enabled==True).all()
  File 
/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/orm/query.py, 
line 1267, in all

return list(self)
  File 
/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/orm/query.py, 
line 1361, in __iter__

return self._execute_and_instances(context)
  File 
/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/orm/query.py, 
line 1364, in _execute_and_instances
result = self.session.execute(querycontext.statement, 
params=self._params, mapper=self._mapper_zero_or_none())
  File 
/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/orm/session.py, 
line 753, in execute

clause, params or {})
  File 
/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/engine/base.py, 
line 824, in execute

return Connection.executors[c](self, object, multiparams, params)
  File 
/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/engine/base.py, 
line 874, in _execute_clauseelement

return self.__execute_context(context)
  File 
/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/engine/base.py, 
line 896, in __execute_context
self._cursor_execute(context.cursor, context.statement, 
context.parameters[0], context=context)
  File 
/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/engine/base.py, 
line 950, in _cursor_execute

self._handle_dbapi_exception(e, statement, parameters, cursor, context)
  File 
/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/engine/base.py, 
line 931, in _handle_dbapi_exception
raise exc.DBAPIError.instance(statement, parameters, e, 
connection_invalidated=is_disconnect)
sqlalchemy.exc.OperationalError: (OperationalError) (2006, 'MySQL server 
has gone away') u'SELECT ...


So, my guess is that we're not handling this error correctly.
How should we be handling it?

Anyway, subsequent to this, we got:

return session.query(Feed).filter(Feed.enabled==True).all()
  File 
/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/orm/query.py, 
line 1267, in all

return list(self)
  File 
/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/orm/query.py, 
line 1361, in __iter__

return self._execute_and_instances(context)
  File 
/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/orm/query.py, 
line 1364, in _execute_and_instances
result = self.session.execute(querycontext.statement, 
params=self._params, mapper=self._mapper_zero_or_none())
  File 
/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/orm/session.py, 
line 753, in execute

clause, params or {})
  File 
/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/engine/base.py, 
line 824, in execute

return Connection.executors[c](self, object, multiparams, params)
  File 
/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/engine/base.py, 
line 872, in _execute_clauseelement

parameters=params
  File 
/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/engine/base.py, 
line 938, in __create_execution_context

return dialect.execution_ctx_cls(dialect, connection=self, **kwargs)
  File 
/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/engine/default.py, 
line 170, in __init__

self.cursor = self.create_cursor()
  File 
/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/engine/default.py, 
line 258, in create_cursor

return self._connection.connection.cursor()
  File 
/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/engine/base.py, 
line 576, in connection
raise exc.InvalidRequestError(Can't reconnect until invalid 
transaction is rolled back)
sqlalchemy.exc.InvalidRequestError: Can't reconnect until invalid 
transaction is rolled back


...until the app was restarted.

Any ideas?

cheers,

Chris

--
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Database locking

2010-04-26 Thread gazza
Hello,

I am using multiple servers to access a sqlite db via sqlachemy. I am
using the latest SQLAlchemy and pysqlite-2.6.0.

I get permenant locking and it causes mayhem. I did rebuild sqlite to
make it --enable-threadsafe.

Whats the approach to handle this problem?

Thanks,
garyc

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Mapping dictionaries with string keys and record values

2010-04-26 Thread Michael Bayer
Torsten Landschoff wrote:

 Thanks for your reply and the remarks! Do you plan to extend
 attribute_mapped_collection to update the key like in my example?

here's some things to note on that:

1. I'm not sure why it wasn't that way already, and I'd want to hear from
Jason Kirtland, its author, on if we are missing something or otherwise
whats up.   I have a vague notion that there was a reason for this, or
maybe not.

2. I wonder if there's a way to make this happen more deeply than within
setattr().   Like the collection internals would include an event to
operate upon the target object that includes the other args from the
collection decorator.

3. corresponding delete() event.  Set the attribute on the replaced object
to None ?   that seems potentially surprising ?


 Be aware that this approach also has it's downside. For example,
 assigning

 item2 = Item()
 item2.notes['color'] = item.notes['color']

 will not work contrary to what one might expect (it generated a conflict
 on the id column). The solution is to have the target collection copy
 the assigned object if it has a key already. But that might be too much
 magic to be easy to understand.

the target can only be in one collection at a time so I would think
item2's id wins.  its a primary key switch.



-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] correct way to handle 'MySQL server has gone away'?

2010-04-26 Thread Michael Bayer
Chris Withers wrote:
 Chris Withers wrote:
 raise exc.InvalidRequestError(Can't reconnect until invalid
 transaction is rolled back)
 sqlalchemy.exc.InvalidRequestError: Can't reconnect until invalid
 transaction is rolled back

 Asking here as it sounds like it might be related.
 It occurred transiently, though, and appears to have resolved itself
 without any intervention. Where would I look to find out what caused the
 invalid transaction and how it was rolled back?

 We've had this occur again, wondered if anyone had any suggestions...

 So, the first error is this:

  return session.query(Feed).filter(Feed.enabled==True).all()
File
 /usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/orm/query.py,
 line 1267, in all
  return list(self)
File
 /usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/orm/query.py,
 line 1361, in __iter__
  return self._execute_and_instances(context)
File
 /usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/orm/query.py,
 line 1364, in _execute_and_instances
  result = self.session.execute(querycontext.statement,
 params=self._params, mapper=self._mapper_zero_or_none())
File
 /usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/orm/session.py,
 line 753, in execute
  clause, params or {})
File
 /usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/engine/base.py,
 line 824, in execute
  return Connection.executors[c](self, object, multiparams, params)
File
 /usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/engine/base.py,
 line 874, in _execute_clauseelement
  return self.__execute_context(context)
File
 /usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/engine/base.py,
 line 896, in __execute_context
  self._cursor_execute(context.cursor, context.statement,
 context.parameters[0], context=context)
File
 /usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/engine/base.py,
 line 950, in _cursor_execute
  self._handle_dbapi_exception(e, statement, parameters, cursor,
 context)
File
 /usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/engine/base.py,
 line 931, in _handle_dbapi_exception
  raise exc.DBAPIError.instance(statement, parameters, e,
 connection_invalidated=is_disconnect)
 sqlalchemy.exc.OperationalError: (OperationalError) (2006, 'MySQL server
 has gone away') u'SELECT ...

 So, my guess is that we're not handling this error correctly.
 How should we be handling it?

you have to rollback the current transaction, and either throw an error or
try the whole transaction again.

 line 576, in connection
  raise exc.InvalidRequestError(Can't reconnect until invalid
 transaction is rolled back)
 sqlalchemy.exc.InvalidRequestError: Can't reconnect until invalid
 transaction is rolled back

 ...until the app was restarted.


MySQL disconnected.  your transaction was gone.  SQLA will reconnect, but
not until you've let it know that you've agreed to chuck your current
transaction on the app side, since its gone on the DB side.


as always, none of these problems ever occur (well disconnects, but the
app will recover), if you ensure that you are doing:


try:
do_my_stuff()
except:
Session.rollback()
raise





-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] further restricting a query provided as raw sql

2010-04-26 Thread Michael Bayer
Chris Withers wrote:
 Michael Bayer wrote:
 Any serious ideas or should I just go sulk in the corner?

 you have to use IN, and you have to generate the SQL every time based on
 the number of values you'd like to put into the IN.

 Does SA have any helper code anywhere for this?

we have the in_() construct.  It should be in the ORM and SQL expression
tutorials:

t1 = Table('mytable', metadata, Column('foo', String))

select([t1]).where(t1.c.foo.in_(['a', 'b', 'c']))


-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Database locking

2010-04-26 Thread Michael Bayer
gazza wrote:
 Hello,

 I am using multiple servers to access a sqlite db via sqlachemy. I am
 using the latest SQLAlchemy and pysqlite-2.6.0.

 I get permenant locking and it causes mayhem. I did rebuild sqlite to
 make it --enable-threadsafe.

 Whats the approach to handle this problem?

one helpful thing is to disable connection pooling.   see
http://www.sqlalchemy.org/docs/reference/dialects/sqlite.html#threading-behavior
.


 Thanks,
 garyc

 --
 You received this message because you are subscribed to the Google Groups
 sqlalchemy group.
 To post to this group, send email to sqlalch...@googlegroups.com.
 To unsubscribe from this group, send email to
 sqlalchemy+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/sqlalchemy?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Re-using labels

2010-04-26 Thread Peter Waller
Let's say I write something like:

fixed_column = cast(my_column.op(/)(2**32), Integer).label(fixed_column)

print select([fixed_column]).where(fixed_column  100)

I get:

SELECT CAST(my_column / :my_columnn_1 AS INTEGER) AS fixed_column
FROM table
WHERE CAST(my_column / :my_column_1 AS INTEGER)  :param_1

Is there any reason fixed_column is not re-used in the where statement? Is
it possible to make this happen? It would make my statements much more
readable.

Thanks,

- Peter

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Mapping dictionaries with string keys and record values

2010-04-26 Thread jason kirtland
On Mon, Apr 26, 2010 at 8:24 AM, Michael Bayer mike...@zzzcomputing.com wrote:
 Torsten Landschoff wrote:

 Thanks for your reply and the remarks! Do you plan to extend
 attribute_mapped_collection to update the key like in my example?

 here's some things to note on that:

 1. I'm not sure why it wasn't that way already, and I'd want to hear from
 Jason Kirtland, its author, on if we are missing something or otherwise
 whats up.   I have a vague notion that there was a reason for this, or
 maybe not.

It's not something that can be easily solved in the general case with
the current API. The mapped collections use a 'keyfunc' to figure out
the dictionary key for loaded instances, for example
'operator.attrgetter(name)' for attribute_mapped_collection(name).
 Mechanically reversing that logic in a setting operation sounds
pretty hard to me, but perhaps if we allowed an 'assignfunc' function
to be supplied that would do the trick.  Internally, the collection
code would call it during a dict['key'] = instance assignment
operation, maybe passing just the key value and the instance:

  def assignfunc(key, instance):
  instance.name = key

For highly constrained types like the attribute- and column-mapped
collections, these functions would be easy to generate.

A good test for the feature would be a mapped collection that maps a
tuple of attributes, such as one created by
attribute_mapped_collection(('x', 'y')).  Assigning collection[1,
2] = instance should assign both instance.x and instance.y in that
case.

 2. I wonder if there's a way to make this happen more deeply than within
 setattr().   Like the collection internals would include an event to
 operate upon the target object that includes the other args from the
 collection decorator.

I have a hunch this is only meaningful for mapped collections-
mutations like list_collection[2:5] would be difficult to translate
and I'm not sure what information one would want to capture there.
Worth a look though.

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Mapping dictionaries with string keys and record values

2010-04-26 Thread Torsten Landschoff
On Mon, 2010-04-26 at 11:24 -0400, Michael Bayer wrote:

 2. I wonder if there's a way to make this happen more deeply than within
 setattr().   Like the collection internals would include an event to
 operate upon the target object that includes the other args from the
 collection decorator.

Sorry, I was unable to follow you here. You think there should be an
event generated to be handled by the collection internals? What
arguments of the decorator are you talking about?

 3. corresponding delete() event.  Set the attribute on the replaced object
 to None ?   that seems potentially surprising ?

In my case it did not matter much since the object is owned by the
mapped collection. So after the delete, it is garbage collected anyway.
As the client code does not know about the key attribute, it would not
notice the change anyway even if it still has a pointer.

For me this is the same as some code still having a reference to a value
that was stored in a dict. If you remove it from the dictionary, you may
still keep a reference but it is not reachable anymore from the dict. To
make this match with the database, I am using cascade=delete-orphan.

  item2 = Item()
  item2.notes['color'] = item.notes['color']
 
  will not work contrary to what one might expect (it generated a conflict
  on the id column). The solution is to have the target collection copy
  the assigned object if it has a key already. But that might be too much
  magic to be easy to understand.
 
 the target can only be in one collection at a time so I would think
 item2's id wins.  its a primary key switch.

Can't it belong to two collections if there is a secondary join?
In plain Python code, both mappings would have a reference to the same
object.

Greetings, Torsten

-- 
DYNAmore Gesellschaft fuer Ingenieurdienstleistungen mbH
Torsten Landschoff

Office Dresden
Tel: +49-(0)351-4519587
Fax: +49-(0)351-4519561

mailto:torsten.landsch...@dynamore.de
http://www.dynamore.de

Registration court: Mannheim, HRB: 109659, based in Karlsruhe,
Managing director:  Prof. Dr. K. Schweizerhof, Dipl.-Math. U. Franz

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Mapping dictionaries with string keys and record values

2010-04-26 Thread Torsten Landschoff
On Mon, 2010-04-26 at 11:08 -0700, jason kirtland wrote:

  1. I'm not sure why it wasn't that way already, and I'd want to hear from
  Jason Kirtland, its author, on if we are missing something or otherwise
  whats up.   I have a vague notion that there was a reason for this, or
  maybe not.
 
 It's not something that can be easily solved in the general case with
 the current API. The mapped collections use a 'keyfunc' to figure out
 the dictionary key for loaded instances, for example
 'operator.attrgetter(name)' for attribute_mapped_collection(name).
  Mechanically reversing that logic in a setting operation sounds
 pretty hard to me, but perhaps if we allowed an 'assignfunc' function
 to be supplied that would do the trick.  Internally, the collection

I agree. The idea of an assignfunc crossed my mind as well.

Greetings, Torsten

-- 
DYNAmore Gesellschaft fuer Ingenieurdienstleistungen mbH
Torsten Landschoff

Office Dresden
Tel: +49-(0)351-4519587
Fax: +49-(0)351-4519561

mailto:torsten.landsch...@dynamore.de
http://www.dynamore.de

Registration court: Mannheim, HRB: 109659, based in Karlsruhe,
Managing director:  Prof. Dr. K. Schweizerhof, Dipl.-Math. U. Franz

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Re: Database locking

2010-04-26 Thread gazza
Thanks Michael. Not sure if this is the only thing I need to do. Why
disable connection pooling?

Thanks,
Garyc


On Apr 26, 10:32 am, Michael Bayer mike...@zzzcomputing.com wrote:
 gazza wrote:
  Hello,

  I am using multiple servers to access a sqlite db via sqlachemy. I am
  using the latest SQLAlchemy and pysqlite-2.6.0.

  I get permenant locking and it causes mayhem. I did rebuild sqlite to
  make it --enable-threadsafe.

  Whats the approach to handle this problem?

 one helpful thing is to disable connection pooling.   
 seehttp://www.sqlalchemy.org/docs/reference/dialects/sqlite.html#threadi...
 .



  Thanks,
  garyc

  --
  You received this message because you are subscribed to the Google Groups
  sqlalchemy group.
  To post to this group, send email to sqlalch...@googlegroups.com.
  To unsubscribe from this group, send email to
  sqlalchemy+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/sqlalchemy?hl=en.

 --
 You received this message because you are subscribed to the Google Groups 
 sqlalchemy group.
 To post to this group, send email to sqlalch...@googlegroups.com.
 To unsubscribe from this group, send email to 
 sqlalchemy+unsubscr...@googlegroups.com.
 For more options, visit this group 
 athttp://groups.google.com/group/sqlalchemy?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Re: Database locking

2010-04-26 Thread Michael Bayer
gazza wrote:
 Thanks Michael. Not sure if this is the only thing I need to do. Why
 disable connection pooling?

it means the app will release filehandles completely when a connection is
released, and also that individual threads in your app will use distinct
connections.  The QueuePool implementation, not the default for SQLite,
will also provide the latter, but I've observed that QueuePool doesn't
really provide much if any performance gain over straight file open/close
per connection.  SQLite really doesn't like multithreaded access on a
single connection.



 Thanks,
 Garyc


 On Apr 26, 10:32 am, Michael Bayer mike...@zzzcomputing.com wrote:
 gazza wrote:
  Hello,

  I am using multiple servers to access a sqlite db via sqlachemy. I am
  using the latest SQLAlchemy and pysqlite-2.6.0.

  I get permenant locking and it causes mayhem. I did rebuild sqlite to
  make it --enable-threadsafe.

  Whats the approach to handle this problem?

 one helpful thing is to disable connection pooling.  
 seehttp://www.sqlalchemy.org/docs/reference/dialects/sqlite.html#threadi...
 .



  Thanks,
  garyc

  --
  You received this message because you are subscribed to the Google
 Groups
  sqlalchemy group.
  To post to this group, send email to sqlalch...@googlegroups.com.
  To unsubscribe from this group, send email to
  sqlalchemy+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/sqlalchemy?hl=en.

 --
 You received this message because you are subscribed to the Google
 Groups sqlalchemy group.
 To post to this group, send email to sqlalch...@googlegroups.com.
 To unsubscribe from this group, send email to
 sqlalchemy+unsubscr...@googlegroups.com.
 For more options, visit this group
 athttp://groups.google.com/group/sqlalchemy?hl=en.

 --
 You received this message because you are subscribed to the Google Groups
 sqlalchemy group.
 To post to this group, send email to sqlalch...@googlegroups.com.
 To unsubscribe from this group, send email to
 sqlalchemy+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/sqlalchemy?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Re: Database locking

2010-04-26 Thread gary clark
Thanks Michael. I am going to do some more research on SQLAlchemy and how it 
handles locks and its interaction with sqlite.
I will try and post my findings next week.

Thanks,
Garyc


--- On Mon, 4/26/10, Michael Bayer mike...@zzzcomputing.com wrote:

 From: Michael Bayer mike...@zzzcomputing.com
 Subject: Re: [sqlalchemy] Re: Database locking
 To: sqlalchemy@googlegroups.com
 Date: Monday, April 26, 2010, 4:39 PM
 gazza wrote:
  Thanks Michael. Not sure if this is the only thing I
 need to do. Why
  disable connection pooling?
 
 it means the app will release filehandles completely when a
 connection is
 released, and also that individual threads in your app will
 use distinct
 connections.  The QueuePool implementation, not the
 default for SQLite,
 will also provide the latter, but I've observed that
 QueuePool doesn't
 really provide much if any performance gain over straight
 file open/close
 per connection.  SQLite really doesn't like
 multithreaded access on a
 single connection.
 
 
 
  Thanks,
  Garyc
 
 
  On Apr 26, 10:32 am, Michael Bayer mike...@zzzcomputing.com
 wrote:
  gazza wrote:
   Hello,
 
   I am using multiple servers to access a
 sqlite db via sqlachemy. I am
   using the latest SQLAlchemy and
 pysqlite-2.6.0.
 
   I get permenant locking and it causes mayhem.
 I did rebuild sqlite to
   make it --enable-threadsafe.
 
   Whats the approach to handle this problem?
 
  one helpful thing is to disable connection
 pooling.  
  seehttp://www.sqlalchemy.org/docs/reference/dialects/sqlite.html#threadi...
  .
 
 
 
   Thanks,
   garyc
 
   --
   You received this message because you are
 subscribed to the Google
  Groups
   sqlalchemy group.
   To post to this group, send email to sqlalch...@googlegroups.com.
   To unsubscribe from this group, send email
 to
   sqlalchemy+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/sqlalchemy?hl=en.
 
  --
  You received this message because you are
 subscribed to the Google
  Groups sqlalchemy group.
  To post to this group, send email to sqlalch...@googlegroups.com.
  To unsubscribe from this group, send email to
  sqlalchemy+unsubscr...@googlegroups.com.
  For more options, visit this group
  athttp://groups.google.com/group/sqlalchemy?hl=en.
 
  --
  You received this message because you are subscribed
 to the Google Groups
  sqlalchemy group.
  To post to this group, send email to sqlalch...@googlegroups.com.
  To unsubscribe from this group, send email to
  sqlalchemy+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/sqlalchemy?hl=en.
 
 
 
 -- 
 You received this message because you are subscribed to the
 Google Groups sqlalchemy group.
 To post to this group, send email to sqlalch...@googlegroups.com.
 To unsubscribe from this group, send email to 
 sqlalchemy+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/sqlalchemy?hl=en.
 
 

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.