[sqlalchemy] Selects failing silently using mysqldb cursors

2009-04-20 Thread claudio.s.marti...@gmail.com

I came across this bug and reported it here
https://sourceforge.net/tracker/index.php?func=detailaid=2776267group_id=22307atid=374932

Since SQLAlchemy is indirectly affected by this I want to hear your
opinion on this matter and on the fix proposed.

On deadlocks or lock timeouts cursors are not raising the expected
exceptions.

Given this scenario:
CREATE TABLE testing1 (a int(11) NOT NULL, PRIMARY KEY (a))
ENGINE=InnoDB;
CREATE TABLE testing2 (a int(11) NOT NULL, PRIMARY KEY (a))
ENGINE=InnoDB;
INSERT INTO testing1 VALUES (12345);
INSERT INTO testing2 VALUES (34567);

And this script:
from sqlalchemy import *

e = create_engine('mysql://localhost/TESTS?
read_default_file=~/.my.cnf')
c1 = e.connect()
c2 = e.connect()

c1.execute('BEGIN')
r = c1.execute('''SELECT * FROM testing1 FOR UPDATE;''')
print 'c1', r.fetchall()

c2.execute('BEGIN')
r = c2.execute('''SELECT * FROM testing2 FOR UPDATE;''')
print 'c2', r.fetchall()

r = c1.execute('''SELECT * FROM testing2 FOR UPDATE;''')
print 'c1', r.fetchall()

This is the output using sqlalchemy 0.5.3:
c1 [(12345L,)]
c2 [(34567L,)]
c1 []

The third statement instead of rasing an exception after timing out,
returns an empty list.

See the attached patch on the sourceforge link for the proposed fix.



--~--~-~--~~~---~--~~
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] Re: connectionless queries with Spatial data (PostGIS)

2009-04-20 Thread Roy Hyunjin Han

 Geospatial support is definitely an external project in any case.
 As soon as something goes in the core, it's now
 linked to our release process, I'm getting the tickets and complaints
 personally, etc., theres no way a huge subject like geo support
 belongs there.

I agree with you that it has to be an external project.  I do not want
to bog down SQLAlchemy's release process.


 I'm just looking for smooth integration with PostGIS
 and other geospatial SQL extensions.If we decide my observation
 that GeoDjango has done a lot of work that needs to be re-done isn't
 really valid, and everything they've done is only useful for Django
 web applications, then that idea should be scrapped, and a simple
 library which builds upon SQLAlchemy expression constructs should be
 created.

We need the SQLAlchemy extension to Spatialite in the lab now, so
we'll get to work on that first.

1. As you suggested, we'll first try looking into making GeoDjango
work as a plugin, in which case we'll get a lot of stuff for free.
2. Otherwise, we'll write our own stripped-down version for Spatialite
and PostGIS.

I'm aiming for a release of the plugin or extension by the end of May.

--~--~-~--~~~---~--~~
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] Re: pyodbc issues

2009-04-20 Thread Michael Mileusnich
Any update on this?

On Fri, Apr 17, 2009 at 6:07 PM, Michael Mileusnich
justmike2...@gmail.comwrote:

 Actually I made a mistake in running some of these py files manually.  The
 tables exist now and this is what I receive:

 2009-04-17 19:04:59,780 INFO sqlalchemy.engine.base.Engine.0x...1230 ()
 2009-04-17 19:04:59,796 INFO sqlalchemy.engine.base.Engine.0x...1230 COMMIT

 C:\Dev\pyschedpython createservers.py

 D:\Python26\lib\site-packages\sqlalchemy-0.5.3-py2.6.egg\sqlalchemy\databases\ms
 sql.py:977: DeprecationWarning: object.__new__() takes no parameters
   return super(MSSQLDialect, cls).__new__(cls, *args, **kwargs)
 2009-04-17 19:05:07,203 INFO sqlalchemy.engine.base.Engine.0x...0270 BEGIN
 2009-04-17 19:05:07,217 INFO sqlalchemy.engine.base.Engine.0x...0270 INSERT
 INTO
  [SERVERS] ([SERVER], [IP], [PORT], [OS], [JSERVER], [STARTED], [STDIN],
 [LOGIN]
 , [CWD], [ASSIGNEDONLY]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
 2009-04-17 19:05:07,217 INFO sqlalchemy.engine.base.Engine.0x...0270
 ['agent1',
 '192.168.0.100', 2000, 0, None, 1, 1, 1, 1, 0]
 2009-04-17 19:05:07,217 INFO sqlalchemy.engine.base.Engine.0x...0270 COMMIT




 On Fri, Apr 17, 2009 at 5:58 PM, Michael Trier mtr...@gmail.com wrote:

 The SERVERS table doesn't exist according to the trace. Did you create
 your tables?

 Sent from mobile

 On Apr 17, 2009, at 7:31 PM, Michael Mileusnich justmike2...@gmail.com
 wrote:

 C:\Dev\pyschedpython createservers.py

 D:\Python26\lib\site-packages\sqlalchemy-0.5.3-py2.6.egg\sqlalchemy\databases\ms
 sql.py:977: DeprecationWarning: object.__new__() takes no parameters
   return super(MSSQLDialect, cls).__new__(cls, *args, **kwargs)
 2009-04-17 18:29:10,421 INFO sqlalchemy.engine.base.Engine.0x...0270 BEGIN
 2009-04-17 18:29:10,437 INFO sqlalchemy.engine.base.Engine.0x...0270
 INSERT INTO
  [SERVERS] ([SERVER], [IP], [PORT], [OS], [JSERVER], [STARTED], [STDIN],
 [LOGIN]
 , [CWD], [ASSIGNEDONLY]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
 2009-04-17 18:29:10,437 INFO sqlalchemy.engine.base.Engine.0x...0270
 ['agent1',
 '192.168.0.100', 2000, 0, None, 1, 1, 1, 1, 0]
 2009-04-17 18:29:10,500 INFO sqlalchemy.engine.base.Engine.0x...0270
 ROLLBACK
 Traceback (most recent call last):
   File createservers.py, line 9, in module
 session.flush()
   File
 d:\python26\lib\site-packages\sqlalchemy-0.5.3-py2.6.egg\sqlalchemy\orm\
 session.py, line 1351, in flush
 self._flush(objects)
   File
 d:\python26\lib\site-packages\sqlalchemy-0.5.3-py2.6.egg\sqlalchemy\orm\
 session.py, line 1422, in _flush
 flush_context.execute()
   File
 d:\python26\lib\site-packages\sqlalchemy-0.5.3-py2.6.egg\sqlalchemy\orm\
 unitofwork.py, line 244, in execute
 UOWExecutor().execute(self, tasks)
   File
 d:\python26\lib\site-packages\sqlalchemy-0.5.3-py2.6.egg\sqlalchemy\orm\
 unitofwork.py, line 707, in execute
 self.execute_save_steps(trans, task)
   File
 d:\python26\lib\site-packages\sqlalchemy-0.5.3-py2.6.egg\sqlalchemy\orm\
 unitofwork.py, line 722, in execute_save_steps
 self.save_objects(trans, task)
   File
 d:\python26\lib\site-packages\sqlalchemy-0.5.3-py2.6.egg\sqlalchemy\orm\
 unitofwork.py, line 713, in save_objects
 task.mapper._save_obj(task.polymorphic_tosave_objects, trans)
   File
 d:\python26\lib\site-packages\sqlalchemy-0.5.3-py2.6.egg\sqlalchemy\orm\
 mapper.py, line 1347, in _save_obj
 c = connection.execute(statement.values(value_params), params)
   File
 d:\python26\lib\site-packages\sqlalchemy-0.5.3-py2.6.egg\sqlalchemy\engi
 ne\base.py, line 824, in execute
 return Connection.executors[c](self, object, multiparams, params)
   File
 d:\python26\lib\site-packages\sqlalchemy-0.5.3-py2.6.egg\sqlalchemy\engi
 ne\base.py, line 874, in _execute_clauseelement
 return self.__execute_context(context)
   File
 d:\python26\lib\site-packages\sqlalchemy-0.5.3-py2.6.egg\sqlalchemy\engi
 ne\base.py, line 896, in __execute_context
 self._cursor_execute(context.cursor, context.statement,
 context.parameters[0
 ], context=context)
   File
 d:\python26\lib\site-packages\sqlalchemy-0.5.3-py2.6.egg\sqlalchemy\engi
 ne\base.py, line 950, in _cursor_execute
 self._handle_dbapi_exception(e, statement, parameters, cursor,
 context)
   File
 d:\python26\lib\site-packages\sqlalchemy-0.5.3-py2.6.egg\sqlalchemy\engi
 ne\base.py, line 931, in _handle_dbapi_exception
 raise exc.DBAPIError.instance(statement, parameters, e,
 connection_invalidat
 ed=is_disconnect)
 sqlalchemy.exc.ProgrammingError: (ProgrammingError) ('42S02', [42S02]
 [Microsof
 t][ODBC SQL Server Driver][SQL Server]Invalid object name 'SERVERS'. (208)
 (SQLE
 xecDirectW); [42000] [Microsoft][ODBC SQL Server Driver][SQL
 Server]Statement(s)
  could not be prepared. (8180)) u'INSERT INTO [SERVERS] ([SERVER], [IP],
 [PORT]
 , [OS], [JSERVER], [STARTED], [STDIN], [LOGIN], [CWD], [ASSIGNEDONLY])
 VALUES (?
 , ?, ?, ?, ?, ?, ?, ?, ?, ?)' ['agent1', '192.168.0.100', 2000, 0, None,
 1, 1, 1
 , 1, 0]

 C:\Dev\pysched


 On Fri, Apr