[sqlalchemy] Default behavior for sqlalchemy_utils.UUIDType

2016-07-29 Thread Jason Libbey
Hi, this is my first post, so if it does not adhere by your guidelines, please let me know and I'll fix it ASAP. I'm using the sqlalchemy_utils.UUIDType as per backend-agnostic-guid-type . from

[sqlalchemy] Re: Understanding behavior of association_proxy

2016-07-29 Thread Eric Wittle
Thank you, that helps! -Eric On Sunday, July 24, 2016 at 7:57:18 PM UTC-4, Eric Wittle wrote: > > I'd like to understand the behavior of association_proxy when creating new > records across a many-to-many table where, in some cases, the joining table > will have additional attribute values

Re: [sqlalchemy] Re: Understanding behavior of association_proxy

2016-07-29 Thread Mike Bayer
On 07/29/2016 06:39 PM, Eric Wittle wrote: I don't have sqlite installed, so I skipped actually creating the engine, all Python versions have sqlite3 included in the distribution itself unless you're on Jython (which I doubt works with SQLA these days)? | fromsqlalchemy

[sqlalchemy] Re: Understanding behavior of association_proxy

2016-07-29 Thread Eric Wittle
OK, my last post I tried to edit the code while I was posting to simplify it, and clearly missed a bit. Here's the case that is failing simplified as much as possible. I get a key error on the last line. I don't have sqlite installed, so I skipped actually creating the engine, but I'm not sure

Re: [sqlalchemy] relationship with DeferredReflection raises NoForeignKeysError

2016-07-29 Thread Mike Bayer
name the COUNTRY_ID column in lower case in your mapping, all UPPERCASE means case sensitive and it will be quoted "COUNTRY_ID", and not match the case-insensitive country_id name in your actual schema. On 07/29/2016 03:29 PM, bsdz wrote: I did some further checking and realized deeper down

Re: [sqlalchemy] nested subqueries in a hybrid expression?

2016-07-29 Thread Brian Cherinka
The @expression as column thing is a bit confusing since in the correlated subquery example in the hybrid attribute section, it looks like you are returning a select? Does the .label() effectively turn it into a column? class User(Base): __tablename__ = 'user' id = Column(Integer,

Re: [sqlalchemy] nested subqueries in a hybrid expression?

2016-07-29 Thread Brian Cherinka
Oh interesting. I didn't know that about the @expression. I'll play around with the as_scalar() as well, and see if I can get something to work. class Wavelength(Base): __tablename__ = 'wavelength' __table_args__ = {'autoload': True, 'schema': 'mangadatadb', 'extend_existing':

Re: [sqlalchemy] nested subqueries in a hybrid expression?

2016-07-29 Thread Mike Bayer
you might need to change more than this, but at least the fundamental thing about @expression is that it has to return a column, not a Query or a select(). On either one, calling as_scalar() will give you a scalar subquery, e.g. a SELECT interpreted as a column. Assuming there's still

Re: [sqlalchemy] relationship with DeferredReflection raises NoForeignKeysError

2016-07-29 Thread Blair Azzopardi
I rechecked everything and I realised that the ForeignKey column is case sensitive. Thanks for your help! On 29 July 2016 at 17:58, Blair Azzopardi wrote: > Interesting. Yes each table was in a different schema in pre-simplified > code and I am using SQL server via pyodbc

[sqlalchemy] nested subqueries in a hybrid expression?

2016-07-29 Thread Brian Cherinka
I'm trying to build a hybrid property / expression in one of my SQLA base classes, and the expression side requires several subqueries and I cannot for the life of me figure out the correct syntax. I've tried many different versions / syntaxes for the expression, using the SQL alchemy

Re: [sqlalchemy] relationship with DeferredReflection raises NoForeignKeysError

2016-07-29 Thread Mike Bayer
On 07/29/2016 12:27 PM, bsdz wrote: Hi I'm trying to use DeferredReflection to encapsulate my data model so that it can easily be instantiated for different environments. However, I am having trouble creating relationships with a NoForeignKeysError being raised. I am guessing it is because

Re: [sqlalchemy] relationship with DeferredReflection raises NoForeignKeysError

2016-07-29 Thread Blair Azzopardi
Interesting. Yes each table was in a different schema in pre-simplified code and I am using SQL server via pyodbc from Linux. I'll try and get a more complete test case shortly. On 29 Jul 2016 5:53 p.m., "Mike Bayer" wrote: > > > On 07/29/2016 12:27 PM, bsdz wrote: >

[sqlalchemy] relationship with DeferredReflection raises NoForeignKeysError

2016-07-29 Thread bsdz
Hi I'm trying to use DeferredReflection to encapsulate my data model so that it can easily be instantiated for different environments. However, I am having trouble creating relationships with a NoForeignKeysError being raised. I am guessing it is because the table metadata generation is being

Re: [sqlalchemy] Parameter injection issue upon db engine creation (tested with db2)

2016-07-29 Thread Mike Bayer
Hello - This issue is specific to the workings of the dialect, in that it is concatenating the URL components into a single string for the DBAPI connect function. As ibm_db_sa is not part of SQLAlchemy, you'd need to report this issue to them. However, the same technique you refer to here

Re: [sqlalchemy] refresh_flush is not triggered when only the primary key is updated

2016-07-29 Thread Mike Bayer
Thanks for the great test case and this would be appropriate to be posted as a bug, since it is a complete description. So, the reason the primary key is not included right now is because primary keys are populated in many different ways on the object, meaning if your code relies upon

[sqlalchemy] Parameter injection issue upon db engine creation (tested with db2)

2016-07-29 Thread Miklós Zakar
Hi, I discovered an issue in db engine creation code. when the code prepares the db connection string it fails to escape the semicolon char. This makes it possible to inject arbitrary parameters in the connection string. Under some circumstances this can be a security issue. PoC: I created two

[sqlalchemy] Generating models for Flask-AppBuilder using flask-sqlacodegen

2016-07-29 Thread Aleksandr Blekh
Hi All, I'm a beginner in Python and Flask ecosystems, trying to create a small proof-of-concept Web application for a research project. I'm using Debian Linux 7.9, PostgreSQL 9.5, SQLAlchemy (latest) and Flask-AppBuilder (latest). Since creating models manually is tedious and error-prone, I

Re: [sqlalchemy] Implementation of params for textual SQL prevents its use in column names (use Python format as workaround)

2016-07-29 Thread Simon King
On Thu, Jul 28, 2016 at 4:33 AM, Andrew M wrote: > Okay, thanks Mike for your comprehensive reply. There is still so much to > learn ... *sigh*. > > Perhaps it's worth including a sentence or two in the docs, helping > overconfident people like myself to understand the

[sqlalchemy] refresh_flush is not triggered when only the primary key is updated

2016-07-29 Thread Lenar Imamutdinov
Hello! Looks like the refresh_flush event is not triggered when the only field to update after flush is the primary key fed from RETURNING clause. However it should, as far as I understand what is mentioned in the documentation. Environment: SQLAlchemy 1.0.14, PostgreSQL 9.5, Python 3.4 Here