Re: [sqlalchemy] Bug in mssql dialect?

2011-03-04 Thread Michael Naber
You are right. Thanks once again.

On Mar 3, 2011, at 11:11, Michael Bayer mike...@zzzcomputing.com wrote:

 That looks certainly like a misconfigured relationship().   Not sure why 
 SQLite would let it pass through (sqlite is in general extremely liberal), 
 but that's clearly a literal string passed to a join expression sent to 
 relationship as in relationship(... primaryjoin=and_(some expression, 
 Edge._discriminator=='use')) or something like that. When using strings 
 for relationship(), the full expression must be a string, not the components.
 
 
 
 On Mar 3, 2011, at 10:55 AM, Michael Naber wrote:
 
 Last line is invalid t-sql. The ‘==’ should just be ‘=’. I get the problem 
 when using mssql but not with sqlite. Saw the bug on sqa version 0.6.6, 
 upgraded to 0.7b2 and still having issue. Please let me know if you need 
 more info and I'll be happy to provide.
  
 Thanks,
 Michael
  
  
 Traceback (most recent call last):
   File C:\Program Files\eclipse-SDK-3.6.2-win32\eclipse\dropins\Pydev 
 1.6.5\plugins\org.python.pydev.debug_1.6.5.2011020317\pysrc\pydevd.py, line 
 1133, in module
 debugger.run(setup['file'], None, None)
   File C:\Program Files\eclipse-SDK-3.6.2-win32\eclipse\dropins\Pydev 
 1.6.5\plugins\org.python.pydev.debug_1.6.5.2011020317\pysrc\pydevd.py, line 
 918, in run
 execfile(file, globals, locals) #execute the script
   File C:\OpsPylonDev\TransformationBA-Trunk\pydev-setup-app.py, line 5, 
 in module
 SetupCommand('setup-app').run(['development.ini'])
   File 
 C:\Python27\lib\site-packages\pastescript-1.7.3-py2.7.egg\paste\script\appinstall.py,
  line 68, in run
 return super(AbstractInstallCommand, self).run(new_args)
   File 
 C:\Python27\lib\site-packages\pastescript-1.7.3-py2.7.egg\paste\script\command.py,
  line 218, in run
 result = self.command()
   File 
 C:\Python27\lib\site-packages\pastescript-1.7.3-py2.7.egg\paste\script\appinstall.py,
  line 456, in command
 self, config_file, section, self.sysconfig_install_vars(installer))
   File 
 C:\Python27\lib\site-packages\pastescript-1.7.3-py2.7.egg\paste\script\appinstall.py,
  line 598, in setup_config
 mod.setup_app, command, filename, section, vars)
   File 
 C:\Python27\lib\site-packages\pastescript-1.7.3-py2.7.egg\paste\script\appinstall.py,
  line 612, in _call_setup_app
 func(command, conf, vars)
   File C:\OpsPylonDev\TransformationBA-Trunk\transformationba\websetup.py, 
 line 34, in setup_app
 insert_data()
   File 
 C:\OpsPylonDev\TransformationBA-Trunk\transformationba\model\data\__init__.py,
  line 42, in insert_data
 inserter.insert()
   File transformationba\model\data\inserters\400technology.py, line 23, in 
 insert
 csharp_app.create_artifacts()
   File 
 C:\OpsPylonDev\TransformationBA-Trunk\transformationba\model\data\technology_data\csharp_app.py,
  line 65, in create_artifacts
 parent.uses.append(component)
   File 
 C:\Python27\lib\site-packages\sqlalchemy-0.7b2-py2.7.egg\sqlalchemy\ext\associationproxy.py,
  line 189, in __get__
 proxy = self._new(_lazy_collection(obj, self.target_collection))
   File 
 C:\Python27\lib\site-packages\sqlalchemy-0.7b2-py2.7.egg\sqlalchemy\ext\associationproxy.py,
  line 233, in _new
 self.collection_class = util.duck_type_collection(lazy_collection())
   File 
 C:\Python27\lib\site-packages\sqlalchemy-0.7b2-py2.7.egg\sqlalchemy\ext\associationproxy.py,
  line 335, in __call__
 return getattr(obj, self.target)
   File 
 C:\Python27\lib\site-packages\sqlalchemy-0.7b2-py2.7.egg\sqlalchemy\orm\attributes.py,
  line 162, in __get__
 return self.impl.get(instance_state(instance),dict_)
   File 
 C:\Python27\lib\site-packages\sqlalchemy-0.7b2-py2.7.egg\sqlalchemy\orm\attributes.py,
  line 414, in get
 value = self.callable_(state, passive)
   File 
 C:\Python27\lib\site-packages\sqlalchemy-0.7b2-py2.7.egg\sqlalchemy\orm\strategies.py,
  line 542, in _load_for_state
 result = q.all()
   File 
 C:\Python27\lib\site-packages\sqlalchemy-0.7b2-py2.7.egg\sqlalchemy\orm\query.py,
  line 1636, in all
 return list(self)
   File 
 C:\Python27\lib\site-packages\sqlalchemy-0.7b2-py2.7.egg\sqlalchemy\orm\query.py,
  line 1746, in __iter__
 return self._execute_and_instances(context)
   File 
 C:\Python27\lib\site-packages\sqlalchemy-0.7b2-py2.7.egg\sqlalchemy\orm\query.py,
  line 1752, in _execute_and_instances
 close_with_result=True).execute(querycontext.statement, self._params)
   File 
 C:\Python27\lib\site-packages\sqlalchemy-0.7b2-py2.7.egg\sqlalchemy\engine\base.py,
  line 1259, in execute
 params)
   File 
 C:\Python27\lib\site-packages\sqlalchemy-0.7b2-py2.7.egg\sqlalchemy\engine\base.py,
  line 1392, in _execute_clauseelement
 compiled_sql, distilled_params
   File 
 C:\Python27\lib\site-packages\sqlalchemy-0.7b2-py2.7.egg\sqlalchemy\engine\base.py,
  line 1500, in _execute_context
 context)
   File 
 

Re: [sqlalchemy] Re: Unmapped Column Error

2011-03-04 Thread Michael Bayer
just an FYI its often easier to just use the actual objects in the 
primary/secondary join instead of the strings.   the string thing is just so 
that order of declaration is not an issue.

On Mar 3, 2011, at 8:39 PM, Doug wrote:

 Thanks for the tip Michael, that solved my problem! It now looks like:
 
 category_association = Table('BankCategoryMap',
 Base.metadata,
 Column(ParentCategoryID, Integer,
 ForeignKey('BankCategories.ID'), primary_key=True),
 Column(ChildCategoryID, Integer,
 ForeignKey('BankCategories.ID'), primary_key=True))
 
 class Category(Base):
__tablename__ = 'BankCategories'
 
id = Column(ID, Integer, primary_key=True)
name = Column(Name, String)
description = Column(Description, String)
active = Column(Active, SmallInteger)
 
 
parents = relationship(Category,
   secondary=category_association,
   primaryjoin=Category.id ==
 BankCategoryMap.c.ChildCategoryID,
 
 secondaryjoin=BankCategoryMap.c.ParentCategoryID == Category.id,
   backref='children')
 
 Which works just dandy.
 
 
 Thanks again,
 Doug
 
 
 On Mar 3, 3:07 pm, Michael Bayer mike...@zzzcomputing.com wrote:
 On Mar 3, 2011, at 5:11 PM, Doug wrote:
 
 
 
 Hello all,
 
 I've just started using SQLAlchemy recently (and it's been great) but
 I have run into a problem recently. I am trying to map a table back to
 itself via a second many-to-many table in a declarative fashion. I
 have this working as so (mapper configuration):
 
 However, when I try it the Declarative way:
 
 category_association = Table('BankCategoryMap',
 Base.metadata,
 Column(ParentCategoryID, Integer,
 ForeignKey('BankCategories.ID'), primary_key=True),
 Column(ChildCategoryID, Integer,
 ForeignKey('BankCategories.ID'), primary_key=True))
 
 class Category(Base):
__tablename__ = 'BankCategories'
 
id = Column(ID, Integer, primary_key=True)
name = Column(Name, String)
description = Column(Description, String)
active = Column(Active, SmallInteger)
 
parents = relationship(Category,
   secondary=category_association,
   primaryjoin=BankCategories.ID ==
 category_association.c.ChildCategoryID,
 
 secondaryjoin=category_association.c.ParentCategoryID ==
 BankCategories.ID,
   backref='children')
 
 You need to use the actual attributes, or a full string, when using the 
 primaryjoin and secondaryjoin arguments.  You can't mix and match operators 
 with strings. Some FAQ on a similar issue is here:  
 http://www.sqlalchemy.org/trac/wiki/FAQ#ImusingDeclarativeandsettingp
 
 
 
 This does not work and I get the following error:
 
 File '/home/doug/pyenv_svn/CreateService/surveyservice/surveyservice/
 controllers/error.py', line 25 in document
  cat.parents
 File '/home/doug/pyenv_svn/CreateService/lib/python2.6/site-packages/
 SQLAlchemy-0.6.5-py2.6.egg/sqlalchemy/orm/attributes.py', line 170 in
 __get__
  instance_dict(instance))
 File '/home/doug/pyenv_svn/CreateService/lib/python2.6/site-packages/
 SQLAlchemy-0.6.5-py2.6.egg/sqlalchemy/orm/attributes.py', line 390 in
 get
  value = callable_(passive=passive)
 File '/home/doug/pyenv_svn/CreateService/lib/python2.6/site-packages/
 SQLAlchemy-0.6.5-py2.6.egg/sqlalchemy/orm/strategies.py', line 670 in
 __call__
  result = q.all()
 File '/home/doug/pyenv_svn/CreateService/lib/python2.6/site-packages/
 SQLAlchemy-0.6.5-py2.6.egg/sqlalchemy/orm/query.py', line 1576 in all
  return list(self)
 File '/home/doug/pyenv_svn/CreateService/lib/python2.6/site-packages/
 SQLAlchemy-0.6.5-py2.6.egg/sqlalchemy/orm/query.py', line 1688 in
 __iter__
  return self._execute_and_instances(context)
 File '/home/doug/pyenv_svn/CreateService/lib/python2.6/site-packages/
 SQLAlchemy-0.6.5-py2.6.egg/sqlalchemy/orm/query.py', line 1693 in
 _execute_and_instances
  mapper=self._mapper_zero_or_none())
 File '/home/doug/pyenv_svn/CreateService/lib/python2.6/site-packages/
 SQLAlchemy-0.6.5-py2.6.egg/sqlalchemy/orm/session.py', line 729 in
 execute
  clause, params or {})
 File '/home/doug/pyenv_svn/CreateService/lib/python2.6/site-packages/
 SQLAlchemy-0.6.5-py2.6.egg/sqlalchemy/engine/base.py', line 1191 in
 execute
  params)
 File '/home/doug/pyenv_svn/CreateService/lib/python2.6/site-packages/
 SQLAlchemy-0.6.5-py2.6.egg/sqlalchemy/engine/base.py', line 1269 in
 _execute_clauseelement
  parameters=params
 File '/home/doug/pyenv_svn/CreateService/lib/python2.6/site-packages/
 SQLAlchemy-0.6.5-py2.6.egg/sqlalchemy/engine/base.py', line 1377 in
 __create_execution_context
  connection=self, **kwargs)
 File '/home/doug/pyenv_svn/CreateService/lib/python2.6/site-packages/
 SQLAlchemy-0.6.5-py2.6.egg/sqlalchemy/engine/default.py', line 388 in
 __init__
  grp,m in 

Re: [sqlalchemy] Deadlock in iterating over a session

2011-03-04 Thread Michael Bayer

On Mar 4, 2011, at 2:58 AM, Lenza McElrath wrote:

 Hello!  I'm iterating over a session to look at all the objects:
 
 for obj in session:
   do_something_cool(obj)
 
 Yesterday this caused what looks like a deadlock in SQLAlchemy code.  Here is 
 the stack I grabbed using gdb:
 /python2.5/sqlalchemy/orm/session.py:1353 (Session.__iter__)
 /python2.5/sqlalchemy/orm/identity.py:184 (WeakInstanceDict.values)
 /python2.5/sqlalchemy/orm/identity.py:188 (WeakInstanceDict.itervalues) ** 
 self._remove_mutex.acquire()
 /python2.5/sqlalchemy/orm/state.py:501 (MutableAttrInstanceState.__resurrect)
 /python2.5/sqlalchemy/orm/attributes.py:925 (Events.run)
 /python2.5/sqlalchemy/orm/mapper.py:2424 (_event_on_resurrect)
 /python2.5/sqlalchemy/util.py:953 (OrderedSet.__iter__)
 /python2.5/sqlalchemy/orm/state.py:477 (MutableAttrInstanceState._cleanup)
 /python2.5/sqlalchemy/orm/identity.py:139A (WeakInstanceDict.remove) ** 
 self._remove_mutex.acquire()
 I'm running SQLAlchemy 0.6.5.  Is this a known issue or am I doing something 
 wrong?

I've never seen that before.A reentrant mutex would fix this but I really 
hate to use those as they have a big performance hit and thats a very critical 
section.   Its true this is also related to mutable attributes which is 
something I'd eventually like to remove entirely - they are pending deprecation 
in 0.7.   Is this issue consistently reproducible and can you send me a test 
case ?   This would be very high priority.  

Not sure if this helps but one of the triggers there is you have an object that 
has mutable attributes on it, which is dirty, and has been garbage collected. 
  The state hangs around in the Session and when accessed resurrects itself.  
At that point, it seems like some other object that was also garbage collected 
starts doing the same thing before the process for object #1 can complete, its 
not clear why that would happen here, thats the point at which I'd want to pdb 
around to see what that's about.


 
 On a somewhat related note, am experiencing the issue where lots of objects 
 in a session significantly reduces performance.  It appears I am experiencing 
 the penalty for using MutableTypes on objects described here: 
 http://readthedocs.org/docs/sqlalchemy/en/latest/core/types.html#base-type-api.
   The doc states:
 
 In order to detect changes, the ORM must create a copy of the value when it 
 is first accessed, so that changes to the current value can be compared 
 against the “clean” database-loaded value. Additionally, when the ORM checks 
 to see if any data requires flushing, it must scan through all instances in 
 the session which are known to have “mutable” attributes and compare the 
 current value of each one to its “clean” value.
 
 It doesn't seem like I should have to pay this penalty because with my type I 
 actually know when any updates occur.  The type just supports 
 models.mutable_value.update(data).  Is there a way to notify the 
 model/session that the value has been updated when someone calls update, so 
 the full scan of all instances is not needed?  Do I need to rewrite the 
 update function to translate models.mutable_value.update(data) to actually 
 generate models.mutable_value = new_mutable_value or is there a better way to 
 do this?

very easy.  Upgrade to 0.7.   All has been resolved there, to support in-place 
mutation detection you use the techniques described at 
http://www.sqlalchemy.org/docs/07/orm/extensions/mutable.html .

Of course you'd be beta testing something I'm not sure anyone is using yet.   
Hopefully no deadlocks though !   :)   (but again, I'd love to fix that 
deadlock, I'll be looking at that today and a test case would be v. helpful)


-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@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] Deadlock in iterating over a session

2011-03-04 Thread Michael Bayer

On Mar 4, 2011, at 10:32 AM, Michael Bayer wrote:

 
 On Mar 4, 2011, at 2:58 AM, Lenza McElrath wrote:
 
 Hello!  I'm iterating over a session to look at all the objects:
 
 for obj in session:
   do_something_cool(obj)
 
 Yesterday this caused what looks like a deadlock in SQLAlchemy code.  Here 
 is the stack I grabbed using gdb:
 /python2.5/sqlalchemy/orm/session.py:1353 (Session.__iter__)
 /python2.5/sqlalchemy/orm/identity.py:184 (WeakInstanceDict.values)
 /python2.5/sqlalchemy/orm/identity.py:188 (WeakInstanceDict.itervalues) ** 
 self._remove_mutex.acquire()
 /python2.5/sqlalchemy/orm/state.py:501 (MutableAttrInstanceState.__resurrect)
 /python2.5/sqlalchemy/orm/attributes.py:925 (Events.run)
 /python2.5/sqlalchemy/orm/mapper.py:2424 (_event_on_resurrect)
 /python2.5/sqlalchemy/util.py:953 (OrderedSet.__iter__)
 /python2.5/sqlalchemy/orm/state.py:477 (MutableAttrInstanceState._cleanup)
 /python2.5/sqlalchemy/orm/identity.py:139A (WeakInstanceDict.remove) ** 
 self._remove_mutex.acquire()
 I'm running SQLAlchemy 0.6.5.  Is this a known issue or am I doing something 
 wrong?
 
 I've never seen that before.A reentrant mutex would fix this but I really 
 hate to use those as they have a big performance hit and thats a very 
 critical section.   Its true this is also related to mutable attributes 
 which is something I'd eventually like to remove entirely - they are pending 
 deprecation in 0.7.   Is this issue consistently reproducible and can you 
 send me a test case ?   This would be very high priority.  
 
 Not sure if this helps but one of the triggers there is you have an object 
 that has mutable attributes on it, which is dirty, and has been garbage 
 collected.   The state hangs around in the Session and when accessed 
 resurrects itself.  At that point, it seems like some other object that was 
 also garbage collected starts doing the same thing before the process for 
 object #1 can complete, its not clear why that would happen here, thats the 
 point at which I'd want to pdb around to see what that's about.


OK I can't reproduce it, but thinking about the problem I think even using an 
RLock wouldn't help anyway since then you'd get a dictionary changed size 
while iterating error.So my current thoughts on this issue are at 
http://www.sqlalchemy.org/trac/ticket/2087 , which includes a patch against 0.7 
which removes the mutexing and takes a different approach to the issue of items 
disappearing while the session is being iterated.   If this issue is one you 
get often, feel free to apply it against 0.7 and try it out.The patch needs 
tests to prove that the mechanism actually works.


-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@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] In-memory sqlite database to blob?

2011-03-04 Thread thatsanicehatyouhave
Hi,

I'd like to write a script that creates an in-memory SQLite database via 
SQLAlchemy, but when I've finished with it I'd like to upload it as a file to a 
server, preferably without ever creating a temporary file on the client side. 
Is this possible?

Cheers,
Demitri

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@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] Deadlock in iterating over a session

2011-03-04 Thread Lenza McElrath
Thanks for the quick response to this as usual.  See me responses below.

On Fri, Mar 4, 2011 at 7:32 AM, Michael Bayer mike...@zzzcomputing.comwrote:


 On Mar 4, 2011, at 2:58 AM, Lenza McElrath wrote:

 Hello!  I'm iterating over a session to look at all the objects:

 for obj in session:
   do_something_cool(obj)

 Yesterday this caused what looks like a deadlock in SQLAlchemy code.  Here
 is the stack I grabbed using gdb:

1. /python2.5/sqlalchemy/orm/session.py:1353 (Session.__iter__)
2. /python2.5/sqlalchemy/orm/identity.py:184 (WeakInstanceDict.values)
3. /python2.5/sqlalchemy/orm/identity.py:188 (
WeakInstanceDict.itervalues) ** self._remove_mutex.acquire()
4. /python2.5/sqlalchemy/orm/state.py:501 (
MutableAttrInstanceState.__resurrect)
5. /python2.5/sqlalchemy/orm/attributes.py:925 (Events.run)
6. /python2.5/sqlalchemy/orm/mapper.py:2424 (_event_on_resurrect)
7. /python2.5/sqlalchemy/util.py:953 (OrderedSet.__iter__)
8. /python2.5/sqlalchemy/orm/state.py:477 (
MutableAttrInstanceState._cleanup)
9. /python2.5/sqlalchemy/orm/identity.py:139A (WeakInstanceDict.remove)** 
 self._remove_mutex.acquire
()

 I'm running SQLAlchemy 0.6.5.  Is this a known issue or am I doing
 something wrong?


 I've never seen that before.A reentrant mutex would fix this but I
 really hate to use those as they have a big performance hit and thats a very
 critical section.   Its true this is also related to mutable attributes
 which is something I'd eventually like to remove entirely - they are pending
 deprecation in 0.7.   Is this issue consistently reproducible and can you
 send me a test case ?   This would be very high priority.

 Not sure if this helps but one of the triggers there is you have an object
 that has mutable attributes on it, which is dirty, and has been garbage
 collected.   The state hangs around in the Session and when accessed
 resurrects itself.  At that point, it seems like some other object that was
 also garbage collected starts doing the same thing before the process for
 object #1 can complete, its not clear why that would happen here, thats the
 point at which I'd want to pdb around to see what that's about.


This issue was in-consistently reproducible, but it is in a production
system where a workaround has been applied, so now it is not-so-reproducible
(hopefully).

Every object has mutable attributes on it, so it is not surprising that
there would be a dirty one in the session.  Here is the do_something_cool
function in case it provides some insight:

def do_something_cool(obj, do_copy=False):
  for obj in session:
if do_copy:
  ret_obj = copy.deepcopy(obj)
else:
  ret_obj = obj

ret_obj._has_been_flagged = True
return ret_obj

I believe do_copy should be False in this situation, but given the weirdness
I would exclude the possibility that it is True.




 On a somewhat related note, am experiencing the issue where lots of objects
 in a session significantly reduces performance.  It appears I am
 experiencing the penalty for using MutableTypes on objects described here:
 http://readthedocs.org/docs/sqlalchemy/en/latest/core/types.html#base-type-api.
 The doc states:

 In order to detect changes, the ORM must create a copy of the value when it
 is first accessed, so that changes to the current value can be compared
 against the “clean” database-loaded value. Additionally, when the ORM checks
 to see if any data requires flushing, it must scan through all instances in
 the session which are known to have “mutable” attributes and compare the
 current value of each one to its “clean” value.

 It doesn't seem like I should have to pay this penalty because with my type
 I actually know when any updates occur.  The type just supports
 models.mutable_value.update(data).  Is there a way to notify the
 model/session that the value has been updated when someone calls update, so
 the full scan of all instances is not needed?  Do I need to rewrite the
 update function to translate models.mutable_value.update(data) to actually
 generate models.mutable_value = new_mutable_value or is there a better way
 to do this?


 very easy.  Upgrade to 0.7.   All has been resolved there, to support
 in-place mutation detection you use the techniques described at
 http://www.sqlalchemy.org/docs/07/orm/extensions/mutable.html .

 Of course you'd be beta testing something I'm not sure anyone is using yet.
   Hopefully no deadlocks though !   :)   (but again, I'd love to fix that
 deadlock, I'll be looking at that today and a test case would be v. helpful)


So there is no way to accomplish this in 0.6?  I was looking at doing it the
way I describe above, but it is not trivial to figure out which
model/session a value is attached to.  And I guess it is theoretically
possible that a value could be connected to two models/sessions.  Definitely
scared of moving to an untested code... but looks like there are lots of
improvements in 0.7 that 

Re: [sqlalchemy] In-memory sqlite database to blob?

2011-03-04 Thread Michael Bayer
you can ATTACH the memory database to a file and then transfer tables using 
insert-from-select.Don't think there's a way to go straight to a stream, 
though.


On Mar 4, 2011, at 4:50 PM, thatsanicehatyouh...@mac.com wrote:

 Hi,
 
 I'd like to write a script that creates an in-memory SQLite database via 
 SQLAlchemy, but when I've finished with it I'd like to upload it as a file to 
 a server, preferably without ever creating a temporary file on the client 
 side. Is this possible?
 
 Cheers,
 Demitri
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 sqlalchemy group.
 To post to this group, send email to sqlalchemy@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 sqlalchemy@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] Deadlock in iterating over a session

2011-03-04 Thread Michael Bayer

On Mar 4, 2011, at 5:09 PM, Lenza McElrath wrote:

 
 So there is no way to accomplish this in 0.6?  I was looking at doing it the 
 way I describe above, but it is not trivial to figure out which model/session 
 a value is attached to.  And I guess it is theoretically possible that a 
 value could be connected to two models/sessions.  Definitely scared of moving 
 to an untested code... but looks like there are lots of improvements in 0.7 
 that might make it worth it...

well, the on-change event required some less than trivial features so its an 
0.7 thing.  The best solution of all is to not use mutable types in the first 
place.   I.e. if you need to change a scalar value in place, do something like 
myobject.value = value.mutate(xyz).



 
 
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 sqlalchemy group.
 To post to this group, send email to sqlalchemy@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 sqlalchemy@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] In-memory sqlite database to blob?

2011-03-04 Thread A.M.

On Mar 4, 2011, at 4:50 PM, thatsanicehatyouh...@mac.com wrote:

 Hi,
 
 I'd like to write a script that creates an in-memory SQLite database via 
 SQLAlchemy, but when I've finished with it I'd like to upload it as a file to 
 a server, preferably without ever creating a temporary file on the client 
 side. Is this possible?

It is possible but potentially difficult. You could accomplish this by using 
the backup facility (sqlite3_backup_*) to push the in-memory database to the 
remote location, perhaps over a network-mounted file share. 
(http://www.sqlite.org/backup.html)

It would likely be easier to use iterdump in pysqlite to generate a database 
dump and push the SQL dump text to a server.

If you are trying to avoid hitting the disk, perhaps you can create the sqlite 
db on an in-memory filesystem. Then you could use normal filesystem operations 
to manipulate the resultant database.

In any case, SQLAlchemy won't be directly helpful here.

Cheers,
M


-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@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] In-memory sqlite database to blob?

2011-03-04 Thread thatsanicehatyouhave

Thanks for the pointers. I'l probably just write it to a file initially to keep 
it simple!

Cheers,
Demitri

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@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.