[sqlalchemy] Re: select count group_by where ?
On Sat, Oct 11, 2008 at 10:24 PM, Michael Bayer [EMAIL PROTECTED] wrote: We should really fix the MSSQL dialect to not be throwing a SystemError when a SQL statement is not successfully interpreted. I guess syntax error would be more appropriate. I can't see anything wrong with the statement otherwise unless MSSQL has a problem with the same column being in GROUP BY as well as an aggregate. I'd get it to work at the SQL prompt first. The list [ ] in a group_by function has caused the error. Lucas --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: select count group_by where ?
On Fri, Oct 10, 2008 at 10:32 AM, Simon [EMAIL PROTECTED] wrote: The statement looks good in my book...what does system error mean exactly? On 10 Okt., 17:15, Lukasz Szybalski [EMAIL PROTECTED] wrote: Hello, Could anybody tell me what is wrong with this select statement? Records is a mapper. group=sqlalchemy.select([Records.TRANS_TYPE,Records.TR_DATE,func.count(Records.TR_DATE).label('date_count')], Records.TRANS_TYPE==29).group_by([Records.TRANS_TYPE,Records.TR_DATE]).execute().fetchall() I get system error.. Ideas? I can't find a full example that works nowhere on the doc pages. Thanks, Lucas -- Did I do the where statement correctly? Lucas here is the error.//. File /usr/local/pythonenv/BASELINE2/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc1-py2.4.egg/sqlalchemy/sql/expression.py, line 1108, in execute return e.execute_clauseelement(self, multiparams, params) File /usr/local/pythonenv/BASELINE2/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc1-py2.4.egg/sqlalchemy/engine/base.py, line 1227, in execute_clauseelement return connection.execute_clauseelement(elem, multiparams, params) File /usr/local/pythonenv/BASELINE2/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc1-py2.4.egg/sqlalchemy/engine/base.py, line 899, in execute_clauseelement return self._execute_compiled(elem.compile(dialect=self.dialect, column_keys=keys, inline=len(params) 1), distilled_params=params) File /usr/local/pythonenv/BASELINE2/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc1-py2.4.egg/sqlalchemy/engine/base.py, line 911, in _execute_compiled self.__execute_raw(context) File /usr/local/pythonenv/BASELINE2/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc1-py2.4.egg/sqlalchemy/engine/base.py, line 920, in __execute_raw self._cursor_execute(context.cursor, context.statement, context.parameters[0], context=context) File /usr/local/pythonenv/BASELINE2/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc1-py2.4.egg/sqlalchemy/engine/base.py, line 962, in _cursor_execute self.dialect.do_execute(cursor, statement, parameters, context=context) File /usr/local/pythonenv/BASELINE2/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc1-py2.4.egg/sqlalchemy/databases/mssql.py, line 814, in do_execute super(MSSQLDialect_pyodbc, self).do_execute(cursor, statement, parameters, context=context, **kwargs) File /usr/local/pythonenv/BASELINE2/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc1-py2.4.egg/sqlalchemy/databases/mssql.py, line 490, in do_execute cursor.execute(SET IDENTITY_INSERT %s OFF % self.identifier_preparer.format_table(context.compiled.statement.table)) SystemError: 'finally' pops bad exception --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: select count group_by where ?
Actually, if TRANS_TYPE is a mapped attribute of the RecordClass class (or whatever its name is), it should be Records.c.TRANS_TYPE. Also, group_by does not take a list but all individual columns as parameters (so just omit those []s). On 10 Okt., 17:38, Lukasz Szybalski [EMAIL PROTECTED] wrote: On Fri, Oct 10, 2008 at 10:32 AM, Simon [EMAIL PROTECTED] wrote: The statement looks good in my book...what does system error mean exactly? On 10 Okt., 17:15, Lukasz Szybalski [EMAIL PROTECTED] wrote: Hello, Could anybody tell me what is wrong with this select statement? Records is a mapper. group=sqlalchemy.select([Records.TRANS_TYPE,Records.TR_DATE,func.count(Records.TR_DATE).label('date_count')], Records.TRANS_TYPE==29).group_by([Records.TRANS_TYPE,Records.TR_DATE]).execute().fetchall() I get system error.. Ideas? I can't find a full example that works nowhere on the doc pages. Thanks, Lucas -- Did I do the where statement correctly? Lucas here is the error.//. File /usr/local/pythonenv/BASELINE2/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc1-py2.4.egg/sqlalchemy/sql/expression.py, line 1108, in execute return e.execute_clauseelement(self, multiparams, params) File /usr/local/pythonenv/BASELINE2/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc1-py2.4.egg/sqlalchemy/engine/base.py, line 1227, in execute_clauseelement return connection.execute_clauseelement(elem, multiparams, params) File /usr/local/pythonenv/BASELINE2/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc1-py2.4.egg/sqlalchemy/engine/base.py, line 899, in execute_clauseelement return self._execute_compiled(elem.compile(dialect=self.dialect, column_keys=keys, inline=len(params) 1), distilled_params=params) File /usr/local/pythonenv/BASELINE2/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc1-py2.4.egg/sqlalchemy/engine/base.py, line 911, in _execute_compiled self.__execute_raw(context) File /usr/local/pythonenv/BASELINE2/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc1-py2.4.egg/sqlalchemy/engine/base.py, line 920, in __execute_raw self._cursor_execute(context.cursor, context.statement, context.parameters[0], context=context) File /usr/local/pythonenv/BASELINE2/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc1-py2.4.egg/sqlalchemy/engine/base.py, line 962, in _cursor_execute self.dialect.do_execute(cursor, statement, parameters, context=context) File /usr/local/pythonenv/BASELINE2/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc1-py2.4.egg/sqlalchemy/databases/mssql.py, line 814, in do_execute super(MSSQLDialect_pyodbc, self).do_execute(cursor, statement, parameters, context=context, **kwargs) File /usr/local/pythonenv/BASELINE2/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc1-py2.4.egg/sqlalchemy/databases/mssql.py, line 490, in do_execute cursor.execute(SET IDENTITY_INSERT %s OFF % self.identifier_preparer.format_table(context.compiled.statement.table)) SystemError: 'finally' pops bad exception --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: select count group_by where ?
group_by does not take a list but all individual columns as parameters (so just omit those []s). has fixed the error. I think the newer version of sqlachemy no longer has Record.c its just Record.somefield... What also confused me was the fact that in order to do where zyx =2 in query you issue filter() and in select you don't have filter() function and you enter your where stuff inside of select. It works now. Thanks, Lucas On Fri, Oct 10, 2008 at 11:46 AM, Simon [EMAIL PROTECTED] wrote: Actually, if TRANS_TYPE is a mapped attribute of the RecordClass class (or whatever its name is), it should be Records.c.TRANS_TYPE. Also, group_by does not take a list but all individual columns as parameters (so just omit those []s). On 10 Okt., 17:38, Lukasz Szybalski [EMAIL PROTECTED] wrote: On Fri, Oct 10, 2008 at 10:32 AM, Simon [EMAIL PROTECTED] wrote: The statement looks good in my book...what does system error mean exactly? On 10 Okt., 17:15, Lukasz Szybalski [EMAIL PROTECTED] wrote: Hello, Could anybody tell me what is wrong with this select statement? Records is a mapper. group=sqlalchemy.select([Records.TRANS_TYPE,Records.TR_DATE,func.count(Records.TR_DATE).label('date_count')], Records.TRANS_TYPE==29).group_by([Records.TRANS_TYPE,Records.TR_DATE]).execute().fetchall() I get system error.. Ideas? I can't find a full example that works nowhere on the doc pages. Thanks, Lucas -- Did I do the where statement correctly? Lucas here is the error.//. File /usr/local/pythonenv/BASELINE2/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc1-py2.4.egg/sqlalchemy/sql/expression.py, line 1108, in execute return e.execute_clauseelement(self, multiparams, params) File /usr/local/pythonenv/BASELINE2/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc1-py2.4.egg/sqlalchemy/engine/base.py, line 1227, in execute_clauseelement return connection.execute_clauseelement(elem, multiparams, params) File /usr/local/pythonenv/BASELINE2/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc1-py2.4.egg/sqlalchemy/engine/base.py, line 899, in execute_clauseelement return self._execute_compiled(elem.compile(dialect=self.dialect, column_keys=keys, inline=len(params) 1), distilled_params=params) File /usr/local/pythonenv/BASELINE2/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc1-py2.4.egg/sqlalchemy/engine/base.py, line 911, in _execute_compiled self.__execute_raw(context) File /usr/local/pythonenv/BASELINE2/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc1-py2.4.egg/sqlalchemy/engine/base.py, line 920, in __execute_raw self._cursor_execute(context.cursor, context.statement, context.parameters[0], context=context) File /usr/local/pythonenv/BASELINE2/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc1-py2.4.egg/sqlalchemy/engine/base.py, line 962, in _cursor_execute self.dialect.do_execute(cursor, statement, parameters, context=context) File /usr/local/pythonenv/BASELINE2/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc1-py2.4.egg/sqlalchemy/databases/mssql.py, line 814, in do_execute super(MSSQLDialect_pyodbc, self).do_execute(cursor, statement, parameters, context=context, **kwargs) File /usr/local/pythonenv/BASELINE2/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc1-py2.4.egg/sqlalchemy/databases/mssql.py, line 490, in do_execute cursor.execute(SET IDENTITY_INSERT %s OFF % self.identifier_preparer.format_table(context.compiled.statement.table)) SystemError: 'finally' pops bad exception -- Python and OpenOffice documents and templates http://lucasmanual.com/mywiki/OpenOffice Fast and Easy Backup solution with Bacula http://lucasmanual.com/mywiki/Bacula --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---