Re: [sqlalchemy] accessing base class on hybrid expressions from the class side

2016-05-10 Thread Mike Bayer



On 05/10/2016 04:14 PM, Brian Cherinka wrote:

Ok, thanks for the response.  What's the timeframe for the 1.1 release?


it will bethis year :)   hopefully before the summer is over.   I 
try to get one major version each year, and I'm pretty busy as this is 
the first full year in a long time I'm employed full time.   1.1 is 
mostly ready for betas and I just need to find the time to close out a 
few more things and put some out.





  In the meantime, I will have a look into adding my own class_
attribute, or using the Comparator.

I tried something like

setattr(datadb.Cube.plateifu, "class_", datadb.Cube.id.class_)

but it didn't seem to work.  But I'll dig a bit deeper.  If I can't get
something working with a 1.0X release, I'll try the 1.1 in bitbucket.


On Tuesday, May 10, 2016 at 2:32:22 PM UTC-4, Mike Bayer wrote:

in 1.1 these hybrids will have the class_ attribute like other
attributes.

Until then you can probably add your own class_ attribute to the object
which you are returning.   Also, using a custom Comparator class (see
the example in the hybrid docs) will also return an instrumented
attribute that should have a class_ attribute.

Or you could try using the 1.1 hybrid_property class yourself, it
should
be compatible with 1.0.   The commits are illustrated in
https://bitbucket.org/zzzeek/sqlalchemy/issues/3653
 but you can
probably
just use the hybrid.py straight from the git repository with 1.0.




On 05/10/2016 02:01 PM, Brian Cherinka wrote:
 >
 > I'm trying to build a query system where given a filter parameter
name,
 > I can figure out which DeclarativeBase class it is attached to.
  I need
 > to do this for a mix of standard InstrumentedAttributes and Hybrid
 > Properties/Expressions. I have several Declarative Base classes with
 > hybrid properties / expressions defined, in addition to the standard
 > InstrumentedAttributes from the actual table.
 >   mydb.dataModelClasses.Cube for example.
 >
 > For a standard attribute, I can access the class using the class_
variable.
 >
 > Standard Attribute on the DeclarativeBase class Cube
 > |
 > type(datadb.Cube.id )
 > sqlalchemy.orm.attributes.InstrumentedAttribute
 >
 > printdatadb.Cube.id.class_
 > mydb.DataModelClasses.Cube
 > |
 >
 > What's the best way to retrieve this same information for a hybrid
 > expression?  My expressions are other types, thus don't have the
class_
 > attribute.  One example of my hybrid property defined in the Cube
class
 >
 > |
 > @hybrid_property
 > defplateifu(self):
 > return'{0}-{1}'.format(self.plate,self.ifu.name
)
 >
 > @plateifu.expression
 > defplateifu(cls):
 > returnfunc.concat(Cube.plate,'-',IFUDesign.name)
 > |
 >
 > |
 > type(datadb.Cube.plateifu)
 > sqlalchemy.sql.functions.concat
 > |
 >
 > Since this property is now a function concat, what's the best way to
 > retrieve the name of the class that this property is attached to,
namely
 > 'mydb.DataModelClasses.Cube'?  It doesn't seem to have a .class_ or
 > .parent attribute.  Is there a way to add a new attribute onto my
hybrid
 > columns that let me access the parent class?
 >
 > I need to do this for a variety of hybrid properties/expressions,
that
 > are all constructed in unique ways.  This particular example is a
 > function concat, however I have others that are of type
 > sqlalchemy.sql.elements.BinaryExpression.
 >
 > Is there a way to generically do this no matter the type of hybrid
 > expression I define?
 >
 > Thanks.
 >
 > --

--
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.


--
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.


Re: [sqlalchemy] accessing base class on hybrid expressions from the class side

2016-05-10 Thread Brian Cherinka
Ok, thanks for the response.  What's the timeframe for the 1.1 release?  In 
the meantime, I will have a look into adding my own class_ attribute, or 
using the Comparator.  

I tried something like

setattr(datadb.Cube.plateifu, "class_", datadb.Cube.id.class_)

but it didn't seem to work.  But I'll dig a bit deeper.  If I can't get 
something working with a 1.0X release, I'll try the 1.1 in bitbucket. 


On Tuesday, May 10, 2016 at 2:32:22 PM UTC-4, Mike Bayer wrote:
>
> in 1.1 these hybrids will have the class_ attribute like other attributes. 
>
> Until then you can probably add your own class_ attribute to the object 
> which you are returning.   Also, using a custom Comparator class (see 
> the example in the hybrid docs) will also return an instrumented 
> attribute that should have a class_ attribute. 
>
> Or you could try using the 1.1 hybrid_property class yourself, it should 
> be compatible with 1.0.   The commits are illustrated in 
> https://bitbucket.org/zzzeek/sqlalchemy/issues/3653 but you can probably 
> just use the hybrid.py straight from the git repository with 1.0. 
>
>
>
>
> On 05/10/2016 02:01 PM, Brian Cherinka wrote: 
> > 
> > I'm trying to build a query system where given a filter parameter name, 
> > I can figure out which DeclarativeBase class it is attached to.  I need 
> > to do this for a mix of standard InstrumentedAttributes and Hybrid 
> > Properties/Expressions. I have several Declarative Base classes with 
> > hybrid properties / expressions defined, in addition to the standard 
> > InstrumentedAttributes from the actual table. 
> >   mydb.dataModelClasses.Cube for example. 
> > 
> > For a standard attribute, I can access the class using the class_ 
> variable. 
> > 
> > Standard Attribute on the DeclarativeBase class Cube 
> > | 
> > type(datadb.Cube.id) 
> > sqlalchemy.orm.attributes.InstrumentedAttribute 
> > 
> > printdatadb.Cube.id.class_ 
> > mydb.DataModelClasses.Cube 
> > | 
> > 
> > What's the best way to retrieve this same information for a hybrid 
> > expression?  My expressions are other types, thus don't have the class_ 
> > attribute.  One example of my hybrid property defined in the Cube class 
> > 
> > | 
> > @hybrid_property 
> > defplateifu(self): 
> > return'{0}-{1}'.format(self.plate,self.ifu.name) 
> > 
> > @plateifu.expression 
> > defplateifu(cls): 
> > returnfunc.concat(Cube.plate,'-',IFUDesign.name) 
> > | 
> > 
> > | 
> > type(datadb.Cube.plateifu) 
> > sqlalchemy.sql.functions.concat 
> > | 
> > 
> > Since this property is now a function concat, what's the best way to 
> > retrieve the name of the class that this property is attached to, namely 
> > 'mydb.DataModelClasses.Cube'?  It doesn't seem to have a .class_ or 
> > .parent attribute.  Is there a way to add a new attribute onto my hybrid 
> > columns that let me access the parent class? 
> > 
> > I need to do this for a variety of hybrid properties/expressions, that 
> > are all constructed in unique ways.  This particular example is a 
> > function concat, however I have others that are of type 
> > sqlalchemy.sql.elements.BinaryExpression. 
> > 
> > Is there a way to generically do this no matter the type of hybrid 
> > expression I define? 
> > 
> > Thanks. 
> > 
> > -- 
>
>

-- 
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.


Re: [sqlalchemy] accessing base class on hybrid expressions from the class side

2016-05-10 Thread Mike Bayer

in 1.1 these hybrids will have the class_ attribute like other attributes.

Until then you can probably add your own class_ attribute to the object 
which you are returning.   Also, using a custom Comparator class (see 
the example in the hybrid docs) will also return an instrumented 
attribute that should have a class_ attribute.


Or you could try using the 1.1 hybrid_property class yourself, it should 
be compatible with 1.0.   The commits are illustrated in 
https://bitbucket.org/zzzeek/sqlalchemy/issues/3653 but you can probably 
just use the hybrid.py straight from the git repository with 1.0.





On 05/10/2016 02:01 PM, Brian Cherinka wrote:


I'm trying to build a query system where given a filter parameter name,
I can figure out which DeclarativeBase class it is attached to.  I need
to do this for a mix of standard InstrumentedAttributes and Hybrid
Properties/Expressions. I have several Declarative Base classes with
hybrid properties / expressions defined, in addition to the standard
InstrumentedAttributes from the actual table.
  mydb.dataModelClasses.Cube for example.

For a standard attribute, I can access the class using the class_ variable.

Standard Attribute on the DeclarativeBase class Cube
|
type(datadb.Cube.id)
sqlalchemy.orm.attributes.InstrumentedAttribute

printdatadb.Cube.id.class_
mydb.DataModelClasses.Cube
|

What's the best way to retrieve this same information for a hybrid
expression?  My expressions are other types, thus don't have the class_
attribute.  One example of my hybrid property defined in the Cube class

|
@hybrid_property
defplateifu(self):
return'{0}-{1}'.format(self.plate,self.ifu.name)

@plateifu.expression
defplateifu(cls):
returnfunc.concat(Cube.plate,'-',IFUDesign.name)
|

|
type(datadb.Cube.plateifu)
sqlalchemy.sql.functions.concat
|

Since this property is now a function concat, what's the best way to
retrieve the name of the class that this property is attached to, namely
'mydb.DataModelClasses.Cube'?  It doesn't seem to have a .class_ or
.parent attribute.  Is there a way to add a new attribute onto my hybrid
columns that let me access the parent class?

I need to do this for a variety of hybrid properties/expressions, that
are all constructed in unique ways.  This particular example is a
function concat, however I have others that are of type
sqlalchemy.sql.elements.BinaryExpression.

Is there a way to generically do this no matter the type of hybrid
expression I define?

Thanks.

--
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.


--
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] accessing base class on hybrid expressions from the class side

2016-05-10 Thread Brian Cherinka

I'm trying to build a query system where given a filter parameter name, I 
can figure out which DeclarativeBase class it is attached to.  I need to do 
this for a mix of standard InstrumentedAttributes and Hybrid 
Properties/Expressions. I have several Declarative Base classes with 
hybrid properties / expressions defined, in addition to the standard 
InstrumentedAttributes from the actual table.  mydb.dataModelClasses.Cube 
for example.

For a standard attribute, I can access the class using the class_ variable. 
 

Standard Attribute on the DeclarativeBase class Cube
type(datadb.Cube.id)
sqlalchemy.orm.attributes.InstrumentedAttribute

print datadb.Cube.id.class_
mydb.DataModelClasses.Cube

What's the best way to retrieve this same information for a hybrid 
expression?  My expressions are other types, thus don't have the class_ 
attribute.  One example of my hybrid property defined in the Cube class

@hybrid_property
def plateifu(self):
return '{0}-{1}'.format(self.plate, self.ifu.name)

@plateifu.expression
def plateifu(cls):
return func.concat(Cube.plate, '-', IFUDesign.name)

type(datadb.Cube.plateifu)
sqlalchemy.sql.functions.concat

Since this property is now a function concat, what's the best way to 
retrieve the name of the class that this property is attached to, namely '
mydb.DataModelClasses.Cube'?  It doesn't seem to have a .class_ or .parent 
attribute.  Is there a way to add a new attribute onto my hybrid columns 
that let me access the parent class?

I need to do this for a variety of hybrid properties/expressions, that are 
all constructed in unique ways.  This particular example is a function 
concat, however I have others that are of type 
sqlalchemy.sql.elements.BinaryExpression. 

Is there a way to generically do this no matter the type of hybrid 
expression I define?

Thanks. 
  

-- 
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.


Re: [sqlalchemy] Re: MSSQL OperationalError when offsetting and ordering by an aggregated column

2016-05-10 Thread Mike Bayer



On 05/10/2016 01:10 PM, Craig Weber wrote:

Great; do you know when this will be released? I'm unfamiliar with
SQLAlchemy's release cadence.


the minor fix releases generally come as a particular point version has 
either had about 6-8 weeks in development, or if it accumulates any 
non-workaround-capable issues.   This issue probably can be worked 
around however there are other non-workaroundable fixes in the release 
already so for 1.0.13 I was hoping to release today or later in the week.








On Tuesday, May 10, 2016 at 10:22:48 AM UTC-5, Craig Weber wrote:

Hello,

I believe I've encountered a bug, but I wanted to verify it here
before polluting the issue tracker.

When I compile the following SQLAlchemy query for postgres,
everything seems to work as expected; however, it fails for MSSQL.

|

|price_sum =sqlalchemy.func.sum(
 table.c['Opportunity Max Amount']
).label('Opportunity Max Amount')

query =sqlalchemy.select(
 columns=[price_sum],
 order_by=sqlalchemy.desc(price_sum),
 offset=1,
).alias("FOO")

rows =conn.execute(query).fetchall()|

|

It seems the generated query is attempting to order by the
un-aggregated column rather than the specified column.

Here is the generated MSSQL query:

|

|SELECT anon_1.[OpportunityMaxAmount]
FROM (
 SELECT
 sum([table_name].[OpportunityMaxAmount])AS
[OpportunityMaxAmount],
 ROW_NUMBER()OVER (ORDER BY [OpportunityMaxAmount]DESC)AS
mssql_rn
 FROM [table_name]
)AS anon_1
WHERE mssql_rn >1|

|

Here's the error message:

|

|sqlalchemy.exc.OperationalError:(pymssql.OperationalError)(8120,b"Column
'80079bd5c7664c5eb6789fbfa49fd10b.Opportunity Max Amount' is invalid
in the
select list because it is not contained in either an aggregate
function or the
GROUP BY clause.DB-Lib error message 20018, severity 16:\nGeneral
SQL Server
error: Check messages from the SQL Server\n")[SQL:'SELECT
anon_1.[Opportunity
Max Amount] \nFROM (SELECT
sum([80079bd5c7664c5eb6789fbfa49fd10b].[Opportunity
Max Amount]) AS [Opportunity Max Amount], ROW_NUMBER() OVER (ORDER BY
[Opportunity Max Amount] DESC) AS mssql_rn \nFROM
[80079bd5c7664c5eb6789fbfa49fd10b]) AS anon_1 \nWHERE mssql_rn >
%(param_1)s']
[parameters:{'param_1':1}]|

|


And here is the working Postgres query for reference:

|SELECT sum(performance_data."Opportunity Max Amount")AS "Opportunity
Max Amount"FROM performance_data ORDER BY "Opportunity Max
Amount"DESC LIMIT ALL OFFSET 1|

Thanks,
Craig

--
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.


--
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: MSSQL OperationalError when offsetting and ordering by an aggregated column

2016-05-10 Thread Craig Weber
Great; do you know when this will be released? I'm unfamiliar with 
SQLAlchemy's release cadence.

On Tuesday, May 10, 2016 at 10:22:48 AM UTC-5, Craig Weber wrote:
>
> Hello,
>
> I believe I've encountered a bug, but I wanted to verify it here before 
> polluting the issue tracker.
>
> When I compile the following SQLAlchemy query for postgres, everything 
> seems to work as expected; however, it fails for MSSQL.
>
> price_sum = sqlalchemy.func.sum(
> table.c['Opportunity Max Amount']
> ).label('Opportunity Max Amount')
>
> query = sqlalchemy.select(
> columns=[price_sum],
> order_by=sqlalchemy.desc(price_sum),
> offset=1,
> ).alias("FOO")
>
> rows = conn.execute(query).fetchall()
>
>
> It seems the generated query is attempting to order by the un-aggregated 
> column rather than the specified column.
>
> Here is the generated MSSQL query:
>
> SELECT anon_1.[Opportunity Max Amount]
> FROM (
> SELECT
> sum([table_name].[Opportunity Max Amount]) AS [Opportunity Max 
> Amount],
> ROW_NUMBER() OVER (ORDER BY [Opportunity Max Amount] DESC) AS mssql_rn
> FROM [table_name]
> ) AS anon_1
> WHERE mssql_rn > 1
>
>
> Here's the error message:
>
> sqlalchemy.exc.OperationalError: (pymssql.OperationalError) (8120, b"Column
> '80079bd5c7664c5eb6789fbfa49fd10b.Opportunity Max Amount' is invalid in the
> select list because it is not contained in either an aggregate function or the
> GROUP BY clause.DB-Lib error message 20018, severity 16:\nGeneral SQL Server
> error: Check messages from the SQL Server\n") [SQL: 'SELECT 
> anon_1.[Opportunity
> Max Amount] \nFROM (SELECT sum([80079bd5c7664c5eb6789fbfa49fd10b].[Opportunity
> Max Amount]) AS [Opportunity Max Amount], ROW_NUMBER() OVER (ORDER BY
> [Opportunity Max Amount] DESC) AS mssql_rn \nFROM
> [80079bd5c7664c5eb6789fbfa49fd10b]) AS anon_1 \nWHERE mssql_rn > %(param_1)s']
> [parameters: {'param_1': 1}]
>
>
>
> And here is the working Postgres query for reference:
>
> SELECT
> sum(performance_data."Opportunity Max Amount") AS "Opportunity Max Amount"
> FROM performance_data
> ORDER BY "Opportunity Max Amount" DESC
> LIMIT ALL
> OFFSET 1
>
> Thanks,
> Craig
>

-- 
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.


Re: [sqlalchemy] MSSQL OperationalError when offsetting and ordering by an aggregated column

2016-05-10 Thread Mike Bayer



On 05/10/2016 11:22 AM, Craig Weber wrote:

Hello,

I believe I've encountered a bug, but I wanted to verify it here before
polluting the issue tracker.

When I compile the following SQLAlchemy query for postgres, everything
seems to work as expected; however, it fails for MSSQL.

|

|price_sum =sqlalchemy.func.sum(
 table.c['Opportunity Max Amount']
).label('Opportunity Max Amount')

query =sqlalchemy.select(
 columns=[price_sum],
 order_by=sqlalchemy.desc(price_sum),
 offset=1,
).alias("FOO")

rows =conn.execute(query).fetchall()|

|

It seems the generated query is attempting to order by the un-aggregated
column rather than the specified column.

Here is the generated MSSQL query:


bug is created at https://bitbucket.org/zzzeek/sqlalchemy/issues/3711 
and the patch is against CI review right now.   commit should be in 30 
minutes.








|

|SELECT anon_1.[OpportunityMaxAmount]
FROM (
 SELECT
 sum([table_name].[OpportunityMaxAmount])AS [OpportunityMaxAmount],
 ROW_NUMBER()OVER (ORDER BY [OpportunityMaxAmount]DESC)AS mssql_rn
 FROM [table_name]
)AS anon_1
WHERE mssql_rn >1|

|

Here's the error message:

|

|sqlalchemy.exc.OperationalError:(pymssql.OperationalError)(8120,b"Column
'80079bd5c7664c5eb6789fbfa49fd10b.Opportunity Max Amount' is invalid in the
select list because it is not contained in either an aggregate function
or the
GROUP BY clause.DB-Lib error message 20018, severity 16:\nGeneral SQL Server
error: Check messages from the SQL Server\n")[SQL:'SELECT
anon_1.[Opportunity
Max Amount] \nFROM (SELECT
sum([80079bd5c7664c5eb6789fbfa49fd10b].[Opportunity
Max Amount]) AS [Opportunity Max Amount], ROW_NUMBER() OVER (ORDER BY
[Opportunity Max Amount] DESC) AS mssql_rn \nFROM
[80079bd5c7664c5eb6789fbfa49fd10b]) AS anon_1 \nWHERE mssql_rn >
%(param_1)s']
[parameters:{'param_1':1}]|

|


And here is the working Postgres query for reference:

|SELECT sum(performance_data."Opportunity Max Amount")AS "Opportunity Max
Amount"FROM performance_data ORDER BY "Opportunity Max Amount"DESC LIMIT
ALL OFFSET 1|

Thanks,
Craig

--
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.


--
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] MSSQL OperationalError when offsetting and ordering by an aggregated column

2016-05-10 Thread Craig Weber
Hello,

I believe I've encountered a bug, but I wanted to verify it here before 
polluting the issue tracker.

When I compile the following SQLAlchemy query for postgres, everything 
seems to work as expected; however, it fails for MSSQL.

price_sum = sqlalchemy.func.sum(
table.c['Opportunity Max Amount']
).label('Opportunity Max Amount')

query = sqlalchemy.select(
columns=[price_sum],
order_by=sqlalchemy.desc(price_sum),
offset=1,
).alias("FOO")

rows = conn.execute(query).fetchall()


It seems the generated query is attempting to order by the un-aggregated 
column rather than the specified column.

Here is the generated MSSQL query:

SELECT anon_1.[Opportunity Max Amount]
FROM (
SELECT
sum([table_name].[Opportunity Max Amount]) AS [Opportunity Max Amount],
ROW_NUMBER() OVER (ORDER BY [Opportunity Max Amount] DESC) AS mssql_rn
FROM [table_name]
) AS anon_1
WHERE mssql_rn > 1


Here's the error message:

sqlalchemy.exc.OperationalError: (pymssql.OperationalError) (8120, b"Column
'80079bd5c7664c5eb6789fbfa49fd10b.Opportunity Max Amount' is invalid in the
select list because it is not contained in either an aggregate function or the
GROUP BY clause.DB-Lib error message 20018, severity 16:\nGeneral SQL Server
error: Check messages from the SQL Server\n") [SQL: 'SELECT anon_1.[Opportunity
Max Amount] \nFROM (SELECT sum([80079bd5c7664c5eb6789fbfa49fd10b].[Opportunity
Max Amount]) AS [Opportunity Max Amount], ROW_NUMBER() OVER (ORDER BY
[Opportunity Max Amount] DESC) AS mssql_rn \nFROM
[80079bd5c7664c5eb6789fbfa49fd10b]) AS anon_1 \nWHERE mssql_rn > %(param_1)s']
[parameters: {'param_1': 1}]



And here is the working Postgres query for reference:

SELECT
sum(performance_data."Opportunity Max Amount") AS "Opportunity Max Amount"
FROM performance_data
ORDER BY "Opportunity Max Amount" DESC
LIMIT ALL
OFFSET 1

Thanks,
Craig

-- 
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.


Re: [sqlalchemy] How to generate a file with DDL in the engine's SQL dialect? How to copy engine?

2016-05-10 Thread Simon King
On Tue, May 10, 2016 at 12:37 PM, Piotr Dobrogost
 wrote:
> On Monday, May 9, 2016 at 5:05:11 PM UTC+2, Mike Bayer wrote:
>>
>>
>> the only thing that is sigificant with "mock" is the first part of the
>> URL.   You can just send the whole URL though, so just like this:
>>
>> mock_engine = create_engine(real_engine.url, strategy="mock", ...)
>
>
> Thanks Mike.
> In addition to DDL that comes from .create_all() there's additional DDL
> created by alembic. Is it possible to filter all log messages generated by
> SA by type of SQL (DDL in this case)?
>

Could you use Alembic's offline mode?

http://alembic.readthedocs.io/en/latest/offline.html

Simon

-- 
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.


Re: [sqlalchemy] How to generate a file with DDL in the engine's SQL dialect? How to copy engine?

2016-05-10 Thread Piotr Dobrogost
On Monday, May 9, 2016 at 5:05:11 PM UTC+2, Mike Bayer wrote:
>
>
> the only thing that is sigificant with "mock" is the first part of the 
> URL.   You can just send the whole URL though, so just like this: 
>
> mock_engine = create_engine(real_engine.url, strategy="mock", ...) 
>

Thanks Mike.
In addition to DDL that comes from .create_all() there's additional DDL 
created by alembic. Is it possible to filter all log messages generated by 
SA by type of SQL (DDL in this case)?

Regards,
Piotr

-- 
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.