Re: [sqlalchemy] custom compiler for GenericFunction

2017-10-23 Thread Антонио Антуан
Yes, it works. Thank you.

пн, 23 окт. 2017 г. в 17:43, Mike Bayer :

> On Mon, Oct 23, 2017 at 6:40 AM, Антонио Антуан 
> wrote:
> > Hello guys.
> >
> > I try to make my own GenericFunction with default compiler and custom
> > compiler for particular dialect. As you see below, always used custom
> > compiler:
> >
> > from sqlalchemy import func, create_engine, Integer
> > from sqlalchemy.ext.compiler import compiles
> > from sqlalchemy.orm import sessionmaker
> > from sqlalchemy.sql.functions import GenericFunction
> >
> > engine_ch = create_engine('clickhouse+native://log:pas@127.0.0.1:9000/db
> ')
> > engine_pg = create_engine('postgresql://log:pas@127.0.0.1:9000/db')
> >
> > ses_pg = sessionmaker(bind=engine_pg)()
> > ses_ch = sessionmaker(bind=engine_ch)()
> >
> >
> > class IntDiv(GenericFunction):
> > type = Integer
> > package = 'custom'
> > name = 'div'
> > identifier = 'div'
> >
> >
> > @compiles(IntDiv)
> > def visit_div_default(element, compiler, **kwargs):
> > return 'div(%s)' % compiler.process(element.clause_expr.element)
> >
> >
> > @compiles(IntDiv, 'clickhouse')
> > def visit_div_ch(element, compiler, **kwargs):
> > return 'intDiv(%s)' % compiler.process(element.clause_expr.element)
> >
> >
> > print(ses_ch.bind.dialect.name)
> > print(ses_ch.query(func.custom.div(1, 2)))
> >
> > print(ses_pg.bind.dialect.name)
> > print(ses_pg.query(func.custom.div(1, 2)))
> >
> >
> > If I not make "@compiles(IntDiv)" (for default dialct), make only
> > @compiles(IntDiv, 'clickhouse) I got this error:
> >
> > Traceback (most recent call last):
> >   File "/home/anton/Projects/proj/core/run/stuff.py", line 31, in
> 
> > print(ses_ch.query(func.custom.div(1, 2)))
> >   File
> >
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/orm/query.py",
> > line 3457, in __str__
> > return str(self._compile_context().statement)
>
>
> Based on that line number, I can see you are on a 1.0.x version of
> SQLAlchemy.   Query.__str__() takes into account the bound dialect
> automatically as of 1.1:
>
>
> http://docs.sqlalchemy.org/en/latest/changelog/migration_11.html#stringify-of-query-will-consult-the-session-for-the-correct-dialect
>
> if you are on 1.0.x or earlier you need to compile from the statement:
>
> query.statement.compile(my_engine)
>
>
>
>
>
>
> >   File
> >
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/elements.py",
> > line 506, in __str__
> > return unicode(self.compile()).encode('ascii', 'backslashreplace')
> >   File "", line 1, in 
> >   File
> >
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/elements.py",
> > line 494, in compile
> > return self._compiler(dialect, bind=bind, **kw)
> >   File
> >
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/elements.py",
> > line 500, in _compiler
> > return dialect.statement_compiler(dialect, self, **kw)
> >   File
> >
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py",
> > line 395, in __init__
> > Compiled.__init__(self, dialect, statement, **kwargs)
> >   File
> >
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py",
> > line 190, in __init__
> > self.string = self.process(self.statement, **compile_kwargs)
> >   File
> >
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py",
> > line 213, in process
> > return obj._compiler_dispatch(self, **kwargs)
> >   File
> >
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/visitors.py",
> > line 81, in _compiler_dispatch
> > return meth(self, **kw)
> >   File
> >
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py",
> > line 1584, in visit_select
> > for name, column in select._columns_plus_names
> >   File
> >
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py",
> > line 1357, in _label_select_column
> > **column_clause_args
> >   File
> >
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/visitors.py",
> > line 93, in _compiler_dispatch
> > return meth(self, **kw)
> >   File
> >
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py",
> > line 615, in visit_label
> > OPERATORS[operators.as_] + \
> >   File
> >
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/ext/compiler.py",
> > line 423, in 
> > lambda *arg, **kw: existing(*arg, **kw))
> >   File
> >
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/ext/compiler.py",
> > line 460, in __call__
> > "compilation handler." % type(element))
> > sqlalchemy.exc.CompileError:  construct has no
> > default compilation handler.
> >
> >
> > Is it possible to override default GenericFunction compiler?
> >
> > --
> 

Re: [sqlalchemy] custom compiler for GenericFunction

2017-10-23 Thread Mike Bayer
On Mon, Oct 23, 2017 at 6:40 AM, Антонио Антуан  wrote:
> Hello guys.
>
> I try to make my own GenericFunction with default compiler and custom
> compiler for particular dialect. As you see below, always used custom
> compiler:
>
> from sqlalchemy import func, create_engine, Integer
> from sqlalchemy.ext.compiler import compiles
> from sqlalchemy.orm import sessionmaker
> from sqlalchemy.sql.functions import GenericFunction
>
> engine_ch = create_engine('clickhouse+native://log:pas@127.0.0.1:9000/db')
> engine_pg = create_engine('postgresql://log:pas@127.0.0.1:9000/db')
>
> ses_pg = sessionmaker(bind=engine_pg)()
> ses_ch = sessionmaker(bind=engine_ch)()
>
>
> class IntDiv(GenericFunction):
> type = Integer
> package = 'custom'
> name = 'div'
> identifier = 'div'
>
>
> @compiles(IntDiv)
> def visit_div_default(element, compiler, **kwargs):
> return 'div(%s)' % compiler.process(element.clause_expr.element)
>
>
> @compiles(IntDiv, 'clickhouse')
> def visit_div_ch(element, compiler, **kwargs):
> return 'intDiv(%s)' % compiler.process(element.clause_expr.element)
>
>
> print(ses_ch.bind.dialect.name)
> print(ses_ch.query(func.custom.div(1, 2)))
>
> print(ses_pg.bind.dialect.name)
> print(ses_pg.query(func.custom.div(1, 2)))
>
>
> If I not make "@compiles(IntDiv)" (for default dialct), make only
> @compiles(IntDiv, 'clickhouse) I got this error:
>
> Traceback (most recent call last):
>   File "/home/anton/Projects/proj/core/run/stuff.py", line 31, in 
> print(ses_ch.query(func.custom.div(1, 2)))
>   File
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/orm/query.py",
> line 3457, in __str__
> return str(self._compile_context().statement)


Based on that line number, I can see you are on a 1.0.x version of
SQLAlchemy.   Query.__str__() takes into account the bound dialect
automatically as of 1.1:

http://docs.sqlalchemy.org/en/latest/changelog/migration_11.html#stringify-of-query-will-consult-the-session-for-the-correct-dialect

if you are on 1.0.x or earlier you need to compile from the statement:

query.statement.compile(my_engine)






>   File
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/elements.py",
> line 506, in __str__
> return unicode(self.compile()).encode('ascii', 'backslashreplace')
>   File "", line 1, in 
>   File
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/elements.py",
> line 494, in compile
> return self._compiler(dialect, bind=bind, **kw)
>   File
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/elements.py",
> line 500, in _compiler
> return dialect.statement_compiler(dialect, self, **kw)
>   File
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py",
> line 395, in __init__
> Compiled.__init__(self, dialect, statement, **kwargs)
>   File
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py",
> line 190, in __init__
> self.string = self.process(self.statement, **compile_kwargs)
>   File
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py",
> line 213, in process
> return obj._compiler_dispatch(self, **kwargs)
>   File
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/visitors.py",
> line 81, in _compiler_dispatch
> return meth(self, **kw)
>   File
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py",
> line 1584, in visit_select
> for name, column in select._columns_plus_names
>   File
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py",
> line 1357, in _label_select_column
> **column_clause_args
>   File
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/visitors.py",
> line 93, in _compiler_dispatch
> return meth(self, **kw)
>   File
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py",
> line 615, in visit_label
> OPERATORS[operators.as_] + \
>   File
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/ext/compiler.py",
> line 423, in 
> lambda *arg, **kw: existing(*arg, **kw))
>   File
> "/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/ext/compiler.py",
> line 460, in __call__
> "compilation handler." % type(element))
> sqlalchemy.exc.CompileError:  construct has no
> default compilation handler.
>
>
> Is it possible to override default GenericFunction compiler?
>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full
> description.
> ---
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe 

Re: [sqlalchemy] CTE on branched relationship

2017-10-23 Thread Jim Shepherd
I don't have the raw SQL that performs this query so I'll take your advice 
on posting to SO to see what is needed.

Thanks,
-Jim

On Monday, October 23, 2017 at 10:07:10 AM UTC-4, Mike Bayer wrote:
>
> On Sat, Oct 21, 2017 at 11:21 AM, Jim Shepherd  > wrote: 
> > I am trying to create a recursive that follows two branches during each 
> > recursion. The data model captures operations that can be performed on 
> > series of data or collectively on sets of series of data. Each operation 
> > wither performs on the data set or data series level. These operations 
> can 
> > be stacked creating chains, i.e., (data sets or data 
> > series)->operations->data set. I am not able to create a recursive CTE 
> that 
> > can following either the data set->operation->data set or data set->data 
> > series->operation->data set paths during each recursion. 
> > 
> > Here are the primary components of the model: 
> > 
> > class DataSeries(Base): 
> > __tablename__ = 'DataSeries' 
> > key = Column('DataSeriesId', Integer, 
> >  Sequence('DataSeries_SEQ'), 
> >  primary_key=True) 
> > dataSetId = Column('DataSetId', Integer, 
> >ForeignKey('DataSet.DataSetId', 
> >   name='DataSeries_DataSet_FK')) 
> > 
> > 
> > class DataSet(Base): 
> > __tablename__ = 'DataSet' 
> > key = Column('DataSetId', Integer, 
> >  Sequence('DataSet_SEQ'), 
> >  primary_key=True) 
> > 
> > 
> > class DataOperation(Base): 
> > __tablename__ = 'DataOperation' 
> > key = Column('DataOperationId', Integer, 
> >  Sequence('DataOperation_SEQ'), 
> >  primary_key=True) 
> > processedDataSetId = Column('ProcessedDataSetId', Integer, 
> > ForeignKey('DataSet.DataSetId', 
> >   
>  name='DataOperation_DataSet_FK')) 
> > 
> > 
> > class DataOperationDataSeries(Base): 
> > __tablename__ = 'DataOperationDataSeries' 
> > operationId = Column('DataOperationId', Integer, 
> >  ForeignKey('DataOperation.DataOperationId', 
> > name='DataOpDataSeries_DataOp_FK'), 
> >  primary_key=True, nullable=False) 
> > dataSeriesId = Column('DataSeriesId', Integer, 
> >   ForeignKey('DataSeries.DataSeriesId', 
> > 
>  name='DataOpDataSeries_DataSeries_FK'), 
> >   primary_key=True, nullable=False) 
> > 
> > 
> > class DataOperationDataSet(Base): 
> > __tablename__ = 'DataOperationDataSet' 
> > operationId = Column('DataOperationId', Integer, 
> >  ForeignKey('DataOperation.DataOperationId', 
> > 
> name='DataOpDataSet_DataOperation_FK'), 
> >  primary_key=True, nullable=False) 
> > dataSetId = Column('DataSetId', Integer, 
> >ForeignKey('DataSet.DataSetId', 
> >   name='DataOpDataSet_DataSet_FK'), 
> >primary_key=True, nullable=False) 
> > 
> > The following CTE does not seem to follow either branch. Removing the 
> union 
> > line will successfully follow of the Data Set->Operation->Data Set path 
> as 
> > expected. 
> > 
> > dsIncluded = session.query(DataSet.key) \ 
> > .filter(DataSet.key == 1) 
> > .cte(name='dsIncluded', recursive=True) 
> > 
> > previousDS = aliased(dsIncluded) 
> > currentDS = aliased(DataSet) 
> > dataSetAlias = aliased(DataSet) 
> > 
> > dsIncluded = dsIncluded.union_all( 
> > session.query(currentDS) 
> >.join(DataOperationDataSet), 
> >.union(DataSeries, DataOperationDataSeries) 
> >.join(DataOperation) 
> >.join(dataSetAlias) 
> >.filter(dataSetAlias.key == previousDS.c.DataSetId) 
> > ) 
> > 
> > I have tried many other options with different joins and unions but with 
> my 
> > lack of experience in SQL I am not able to figure out how to get his to 
> > work. Any help is appreciated. Let me know if more information would be 
> > helpful. 
>
> are you able to create a raw SQL statement that does the thing you 
> need? I can help you translate any SQL into a SQLAlchemy-style 
> query.Working out the actual SQL here is a lot more work, however 
> you can likely get help with that part from a place like stackoverflow 
> if nobody here is able to assist, just phrase your question in terms 
> of CREATE TABLE and SELECT statements and tag it as "SQL", so the 
> generic audience of SQL developers can chip in. 
>
>
>
> > 
> > Thanks, 
> > Jim 
> > 
> > -- 
> > SQLAlchemy - 
> > The Python SQL Toolkit and Object Relational Mapper 
> > 
> > http://www.sqlalchemy.org/ 
> > 
> > To post example code, please provide an MCVE: 

Re: [sqlalchemy] CTE on branched relationship

2017-10-23 Thread Mike Bayer
On Sat, Oct 21, 2017 at 11:21 AM, Jim Shepherd  wrote:
> I am trying to create a recursive that follows two branches during each
> recursion. The data model captures operations that can be performed on
> series of data or collectively on sets of series of data. Each operation
> wither performs on the data set or data series level. These operations can
> be stacked creating chains, i.e., (data sets or data
> series)->operations->data set. I am not able to create a recursive CTE that
> can following either the data set->operation->data set or data set->data
> series->operation->data set paths during each recursion.
>
> Here are the primary components of the model:
>
> class DataSeries(Base):
> __tablename__ = 'DataSeries'
> key = Column('DataSeriesId', Integer,
>  Sequence('DataSeries_SEQ'),
>  primary_key=True)
> dataSetId = Column('DataSetId', Integer,
>ForeignKey('DataSet.DataSetId',
>   name='DataSeries_DataSet_FK'))
>
>
> class DataSet(Base):
> __tablename__ = 'DataSet'
> key = Column('DataSetId', Integer,
>  Sequence('DataSet_SEQ'),
>  primary_key=True)
>
>
> class DataOperation(Base):
> __tablename__ = 'DataOperation'
> key = Column('DataOperationId', Integer,
>  Sequence('DataOperation_SEQ'),
>  primary_key=True)
> processedDataSetId = Column('ProcessedDataSetId', Integer,
> ForeignKey('DataSet.DataSetId',
>name='DataOperation_DataSet_FK'))
>
>
> class DataOperationDataSeries(Base):
> __tablename__ = 'DataOperationDataSeries'
> operationId = Column('DataOperationId', Integer,
>  ForeignKey('DataOperation.DataOperationId',
> name='DataOpDataSeries_DataOp_FK'),
>  primary_key=True, nullable=False)
> dataSeriesId = Column('DataSeriesId', Integer,
>   ForeignKey('DataSeries.DataSeriesId',
>  name='DataOpDataSeries_DataSeries_FK'),
>   primary_key=True, nullable=False)
>
>
> class DataOperationDataSet(Base):
> __tablename__ = 'DataOperationDataSet'
> operationId = Column('DataOperationId', Integer,
>  ForeignKey('DataOperation.DataOperationId',
> name='DataOpDataSet_DataOperation_FK'),
>  primary_key=True, nullable=False)
> dataSetId = Column('DataSetId', Integer,
>ForeignKey('DataSet.DataSetId',
>   name='DataOpDataSet_DataSet_FK'),
>primary_key=True, nullable=False)
>
> The following CTE does not seem to follow either branch. Removing the union
> line will successfully follow of the Data Set->Operation->Data Set path as
> expected.
>
> dsIncluded = session.query(DataSet.key) \
> .filter(DataSet.key == 1)
> .cte(name='dsIncluded', recursive=True)
>
> previousDS = aliased(dsIncluded)
> currentDS = aliased(DataSet)
> dataSetAlias = aliased(DataSet)
>
> dsIncluded = dsIncluded.union_all(
> session.query(currentDS)
>.join(DataOperationDataSet),
>.union(DataSeries, DataOperationDataSeries)
>.join(DataOperation)
>.join(dataSetAlias)
>.filter(dataSetAlias.key == previousDS.c.DataSetId)
> )
>
> I have tried many other options with different joins and unions but with my
> lack of experience in SQL I am not able to figure out how to get his to
> work. Any help is appreciated. Let me know if more information would be
> helpful.

are you able to create a raw SQL statement that does the thing you
need? I can help you translate any SQL into a SQLAlchemy-style
query.Working out the actual SQL here is a lot more work, however
you can likely get help with that part from a place like stackoverflow
if nobody here is able to assist, just phrase your question in terms
of CREATE TABLE and SELECT statements and tag it as "SQL", so the
generic audience of SQL developers can chip in.



>
> Thanks,
> Jim
>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full
> description.
> ---
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 

[sqlalchemy] custom compiler for GenericFunction

2017-10-23 Thread Антонио Антуан
Hello guys.

I try to make my own GenericFunction with default compiler and custom 
compiler for particular dialect. As you see below, always used custom 
compiler:

from sqlalchemy import func, create_engine, Integer
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.orm import sessionmaker
from sqlalchemy.sql.functions import GenericFunction

engine_ch = create_engine('clickhouse+native://log:pas@127.0.0.1:9000/db')
engine_pg = create_engine('postgresql://log:pas@127.0.0.1:9000/db')

ses_pg = sessionmaker(bind=engine_pg)()
ses_ch = sessionmaker(bind=engine_ch)()


class IntDiv(GenericFunction):
type = Integer
package = 'custom'
name = 'div'
identifier = 'div'


@compiles(IntDiv)
def visit_div_default(element, compiler, **kwargs):
return 'div(%s)' % compiler.process(element.clause_expr.element)


@compiles(IntDiv, 'clickhouse')
def visit_div_ch(element, compiler, **kwargs):
return 'intDiv(%s)' % compiler.process(element.clause_expr.element)


print(ses_ch.bind.dialect.name)
print(ses_ch.query(func.custom.div(1, 2)))

print(ses_pg.bind.dialect.name)
print(ses_pg.query(func.custom.div(1, 2)))


If I not make "@compiles(IntDiv)" (for default dialct), make only 
@compiles(IntDiv, 'clickhouse) I got this error:

Traceback (most recent call last):
  File "/home/anton/Projects/proj/core/run/stuff.py", line 31, in 
print(ses_ch.query(func.custom.div(1, 2)))
  File 
"/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/orm/query.py",
 line 3457, in __str__
return str(self._compile_context().statement)
  File 
"/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/elements.py",
 line 506, in __str__
return unicode(self.compile()).encode('ascii', 'backslashreplace')
  File "", line 1, in 
  File 
"/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/elements.py",
 line 494, in compile
return self._compiler(dialect, bind=bind, **kw)
  File 
"/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/elements.py",
 line 500, in _compiler
return dialect.statement_compiler(dialect, self, **kw)
  File 
"/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py",
 line 395, in __init__
Compiled.__init__(self, dialect, statement, **kwargs)
  File 
"/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py",
 line 190, in __init__
self.string = self.process(self.statement, **compile_kwargs)
  File 
"/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py",
 line 213, in process
return obj._compiler_dispatch(self, **kwargs)
  File 
"/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/visitors.py",
 line 81, in _compiler_dispatch
return meth(self, **kw)
  File 
"/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py",
 line 1584, in visit_select
for name, column in select._columns_plus_names
  File 
"/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py",
 line 1357, in _label_select_column
**column_clause_args
  File 
"/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/visitors.py",
 line 93, in _compiler_dispatch
return meth(self, **kw)
  File 
"/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py",
 line 615, in visit_label
OPERATORS[operators.as_] + \
  File 
"/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/ext/compiler.py",
 line 423, in 
lambda *arg, **kw: existing(*arg, **kw))
  File 
"/home/anton/Projects/proj/.venv/lib/python2.7/site-packages/sqlalchemy/ext/compiler.py",
 line 460, in __call__
"compilation handler." % type(element))
sqlalchemy.exc.CompileError:  construct has no default 
compilation handler.


Is it possible to override default GenericFunction compiler? 

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] Re: sqlalchemy.exc.InterfaceError: (sqlite3.InterfaceError) Error binding parameter 0 - probably unsupported type. [SQL: 'UPDATE ruleresult SET graded_by=? WHERE ruleresult.ruleresultid =

2017-10-23 Thread Osnat Weissberg
Hi,

Please disregard. I found the problem in my code.

Thanks,
  Osnat

On Sunday, October 22, 2017 at 4:41:26 PM UTC+3, Osnat Weissberg wrote:
>
> Hi,
>
> I have the table:
>
> class RuleResult(Base):
> __tablename__ = 'ruleresult'
> ruleresultid = Column(Integer, primary_key=True)
> graded_by = Column(String(45))
>
>
> I can successfully insert new rows:
>
> rule_res_record = dbmodel.RuleResult(
>   graded_by = 'somestring'
>)
> db.add(rule_res_record) # db is an alchemy session
>
>
>
> But when I try to update it fails with the error:
> row = db.query(RuleResult).first()
> row.graded_by = 'a new string'
>
> # row graded_by is now a Tuple ('a new string',) even though I assigned a 
> string and db.commit() fails
>
> Thanks,
>
>  Osnat
>
>
>

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.