Re: [sqlalchemy] skipping MSSQL TIMESTAMP column on INSERT

2015-12-11 Thread Mike Bayer
On 12/11/2015 01:12 PM, mdob wrote: > | > > @event.listens_for(Table,'column_reflect') > defreceive_column_reflect(inspector,table,column_info): > ifisinstance(column_info['type'],TIMESTAMP): > column_info['default']=FetchedValue() > the reflection wants to assume the

Re: [sqlalchemy] Having trouble using .update() with polymorphic classes

2015-12-15 Thread Mike Bayer
On 12/15/2015 06:26 PM, Gerald Thibault wrote: > I can't figure out the syntax to issue an update, everything I try (attr > name, column name, attribute) results in "unconsumed column names". > > Am I doing something wrong here? MoreTest is mapped using joined table inheritance, mapped to the

Re: [sqlalchemy] Reflection of table/columns comments

2015-12-15 Thread Mike Bayer
On 12/15/2015 07:46 AM, Lele Gaifax wrote: > Hi all, > > I'd like to investigate a possible "special" usage/abuse of comments on schema > objects, available for example under PostgreSQL. > > In many applications, I use the "info" slot of table's columns to store visual > settings, mainly a

Re: [sqlalchemy] Using Hybrids for encryption with varying keys

2015-12-15 Thread Mike Bayer
the hybrid method itself refers to those columns. you can put any SQL / Python expression you want inside the hybrid. There's an early intro to the hybrid concept at http://techspot.zzzeek.org/2011/10/21/hybrids-and-value-agnostic-types/ which shows some examples like this. On 12/14/2015

Re: [sqlalchemy] automap : problem with two relationships on same foreign key

2016-01-03 Thread Mike Bayer
On 01/03/2016 02:43 PM, yoch.me...@gmail.com wrote: > I've added theses lines here > > : > > | >

Re: [sqlalchemy] automap : problem with two relationships on same foreign key

2016-01-03 Thread Mike Bayer
there's actually two if you put your check everywhere it would be needed (I already tried when you first suggested that it warn, which is the origin of my response that this is not a one liner). the warning here is doable it just needs more state to be tracked as automap runs. if you want to

Re: [sqlalchemy] I am getting Proxy error (and the application went down) while running the Delete/Insert/Update queries using SQL Alchemy database adopter

2016-01-01 Thread Mike Bayer
SQLAlchemy is not a database driver and does not replace pyodbc. If you are using a database like MS SQL Server, pyodbc is still the default driver if you are connecting with a URL like "mssql://".Also, an application can't switch in place from pyodbc to SQLAlchemy, "installing" is not

Re: [sqlalchemy] Populating foreign key columns when a relationship is set

2016-01-01 Thread Mike Bayer
On 01/01/2016 01:56 PM, Yegor Roganov wrote: > Is there an option to make sqlalchemy populate foreign key column(s) > when a relationship is set? > Basically I want the following: > > child.parent = parent > assert child.parent_id == parent.id just call session.flush() and this assertion will

Re: [sqlalchemy] automap : problem with two relationships on same foreign key

2016-01-02 Thread Mike Bayer
On 01/02/2016 11:38 AM, yoch.me...@gmail.com wrote: > Thank you. > > I hesitate between using this way, or explicitly specify the relationship > (is this a good idea? In my test I found 3 relations after prepare()) : it's fine to do that. Automap is still building its own relationship as well

Re: [sqlalchemy] how to pick up constraint violation errors in Alchemy

2016-01-02 Thread Mike Bayer
On 01/02/2016 01:02 PM, Krishnakant wrote: > hello all, > I wish to know how I can pick up the constraint failure errors in my code? > I think I would probably have to pick up the errors in a try: except: > system? that is correct. > But What is the exact way of picking up the message? You'd

Re: [sqlalchemy] Re: Connection pools

2016-01-06 Thread Mike Bayer
On 01/06/2016 08:09 AM, Chris Wood wrote: > The project is actually using mod_wsgi (presumably using MPM) - this > seems to explain the rapid increase in the number of connections. It's > been suggested that implementing SQLRelay could be a solution. Is this > sensible? Are there any (better?)

Re: [sqlalchemy] Creating children objects within __init__

2016-01-05 Thread Mike Bayer
On 01/05/2016 10:29 PM, Jim Shepherd wrote: > I am trying to create a class (Model) that ensures that when an instance > is created, a specific set of children objects (Parameters) exist based > on a separate relationship (Option) and if not, delete or add objects > (Parameters) as necessary.

Re: [sqlalchemy] expired model does not reload relationships on get()

2016-01-07 Thread Mike Bayer
On 01/07/2016 08:04 PM, Christopher Lee wrote: > > I have a simple setup where I create two Nodes connected by an Edge, > where the Edge should be eagerly loaded when the parent is loaded. If I > query the Node with a get(), it issues a select to refresh it, but then > if I access its

Re: [sqlalchemy] Is it possible to undefer several groups in one query?

2016-01-09 Thread Mike Bayer
this is a regression which appeared in 0.9, https://bitbucket.org/zzzeek/sqlalchemy/issues/3623/undefer_group-hasnt-supported-multiple is set up and is fixed for version 1.0.12 in 61d2ceb681cd52c91a6657a6c4a271dab895d80a. thanks for reporting! On 01/09/2016 05:32 AM, sander wrote: > Hi, > I

Re: [sqlalchemy] Is there an Object Cache library available for SQLAlchemy?

2016-01-05 Thread Mike Bayer
On 01/05/2016 06:56 PM, cyril.boutei...@clearlabs.com wrote: > I'm working on a new project written in Python with Flask & SQLAlchemy. > The latter seems like a fine ORM but doesn't seem to consider caching as > its responsibility. > > It provides some examples on how to leverage dogpile.cache

Re: [sqlalchemy] automap : problem with two relationships on same foreign key

2016-01-03 Thread Mike Bayer
On 01/03/2016 07:00 AM, yoch.me...@gmail.com wrote: > OK, thanks you. > > I think it's a good idea to issue a warning in such cases. unfortunately this is a difficult situation to detect since it is a valid use case to present a mapped class that already has relationships present on it, which

Re: [sqlalchemy] automap : problem with two relationships on same foreign key

2016-01-01 Thread Mike Bayer
you need to use the name generation functions name_for_scalar_relationship() and/or name_for_collection_relationship() to produce different names in each case. The "constraint" parameter passed as we see in

Re: [sqlalchemy] Bulk insertion with null values

2016-01-06 Thread Mike Bayer
I don't have a solution for that at the moment other than to use a straight Core insert, if there aren't other complicating factors. bulk_insert_mappings() tries to keep the same contract as that of a regular Session.flush(), where None means to "omit" the value, which has affects whether or not

Re: [sqlalchemy] checking unloaded attributes

2016-01-06 Thread Mike Bayer
On 01/06/2016 04:35 PM, Christopher Lee wrote: > > My code tests to see if an column on a model is loaded, in part because > I merge partial models to perform a sparse update on the database. I do > that by checking the __dict__ of the model, though sqlalchemy.inspect > also works. > > Using

Re: [sqlalchemy] using savepoint transactions in unittests for a webapp which uses a scoped session?

2015-12-20 Thread Mike Bayer
On 12/20/2015 07:16 PM, Gerald Thibault wrote: > I've been struggling with this for a few days now, and I've tried a > whole slew of different approaches, but I'm just missing something. > > I started with the example > at >

[sqlalchemy] SQLAlchemy 1.0. 11 Released

2015-12-22 Thread Mike Bayer
SQLAlchemy release 1.0.11 is now available. Release 1.0.11, only twelve days after 1.0.10's release, is expedited to correct for one ORM-related regression introduced by a 1.0.10 fix; some other fairly significant bugfixes involving more recently added features, all reported subsequent to the

Re: [sqlalchemy] Better way of joining a table in two different ways?

2015-12-24 Thread Mike Bayer
On 12/24/2015 12:12 AM, Sohail Khan wrote: > I couldn't figure out a better description or explanation on what I'm > trying to do so I instead wrote a sql query that I want to perform and > tried getting as close as possible to a result that I wanted. I wanted > to know if there was a better

Re: [sqlalchemy] can I use tables generated by ORM via sql expression language for select queries

2015-12-27 Thread Mike Bayer
On 12/26/2015 11:44 PM, Krishnakant wrote: > Hi, > The subject says it all. > I have classes inheriting the base and thus my tables are created using > ORM. > But I wish to use sql expression language for queries, particularly bulk > selects for faster performance. > So is this possible and how?

Re: [sqlalchemy] Creating New Tables from SQL DDL Components

2015-12-27 Thread Mike Bayer
On 12/27/2015 10:48 AM, Philip Martin wrote: > I am integrating a new data source that provides schema data and > versioning in text files. The schema is comprised of several > sub-schemas, and overall, contains over 250+ tables. The data model is > actually very good, with lots of skinny

Re: [sqlalchemy] in-place modification of queries?

2015-12-28 Thread Mike Bayer
not through the current API, no. you'd need to write some modifier to the @generative decorator and basically tinker with things to make it do that. On 12/28/2015 06:18 AM, Chris Withers wrote: > Hi All, > > Is there anything I can do to make Query instance non-generative? > > query =

Re: [sqlalchemy] Re: use of replace

2015-12-28 Thread Mike Bayer
if you're using Postgresql you'd want to look into replace(): http://www.postgresql.org/docs/9.3/static/functions-string.html e.g. query.filter(func.replace(MyClass.column, ' ', '_') == 'some_other_value') though if 'someothervalue' is an in-Python value and your database doesn't have

Re: [sqlalchemy] Re: Connection pools

2015-12-21 Thread Mike Bayer
On 12/21/2015 07:44 PM, Chris Wood wrote: > Ah, ok - thanks for the explanation - this is different to how I'd been > led to believe it worked! However, I know that even when I'm the only > person testing the application, I'm still getting a large number of > connections. Is there a likely

Re: [sqlalchemy] Combined column_expression + process_result_value for custom/decorated type not working?

2015-12-21 Thread Mike Bayer
On 12/21/2015 08:06 AM, Bernardo wrote: > Hi, > > I'm trying to use a custom BYTEA-based type on PostgreSQL (9.2) on > SQLAlchemy 1.0.9., e.g. > > | > class MySpecialBytea(types.TypeDecorator): > impl = BYTEA > > def process_result_value(self, value, dialect): > print

Re: [sqlalchemy] polymorphic eager loading

2015-11-24 Thread Mike Bayer
On 11/24/2015 06:14 PM, Christopher Lee wrote: > > I am having a problem with SQLAlchemy 1.0.9 that cropped up when I > upgraded from 0.8. this is a nicely written test but I get the same recursion overflow error when I run it in 0.8, 0.9, and 1.0, even back in 0.8.3. Can you provide a script

Re: [sqlalchemy] polymorphic eager loading

2015-11-24 Thread Mike Bayer
ity map is getting confused. > (e.g., it is joining against the innermost anon_1 subquery in the > bad case, and against the todo_elements_1 reference in the good > case, which is why the good case is forming a nice tree.) > > On Tue, Nov 24, 2015 at 3:49 PM, Mike

Re: [sqlalchemy] Creating PostgreSQL Index with ASC/DESC and NULLS FIRST/LAST

2015-11-23 Thread Mike Bayer
On 11/23/2015 03:01 PM, Florian Rüchel wrote: > Hey, > > I want to execute the following statement in the most SQLAlchemy way > possible: > > CREATE INDEX ix_user_points ON "user" (points DESC NULLS LAST); > > So I want to add a "DESC NULLS LAST" or equivalent as per documentation >

Re: [sqlalchemy] PostgreSQL table inheritance with "postgresql_inherits" does not take "add_is_dependent_on" into account

2015-11-23 Thread Mike Bayer
arent" ). It gives the same error if I try to run the code in a > GUI with the inherited table name quoted, without (the quoting) > though it works. > > On Mon, Nov 23, 2015 at 6:55 PM Mike Bayer <mike...@zzzcomputing.com > <mailto:mike...@zzzcomputing.

Re: [sqlalchemy] PostgreSQL table inheritance with "postgresql_inherits" does not take "add_is_dependent_on" into account

2015-11-23 Thread Mike Bayer
the right order - the problem is that the DDL contains INHERITS ( > "parent" ). It gives the same error if I try to run the code in a > GUI with the inherited table name quoted, without (the quoting) > though it works. > > On Mon, Nov 23, 2015 at 6:

Re: [sqlalchemy] polymorphic eager loading

2015-11-25 Thread Mike Bayer
sqlalchemy/orm/util.py", > line 398, in __getattr__ > raise AttributeError(key) > AttributeError: Node > > > > On Wed, Nov 25, 2015 at 10:21 AM, Christopher Lee <c...@sirdodger.net > <mailto:c...@sirdodger.net>> wrote: >

Re: [sqlalchemy] polymorphic eager loading

2015-11-25 Thread Mike Bayer
On 11/25/2015 02:20 PM, Mike Bayer wrote: > > > On 11/25/2015 01:32 PM, Christopher Lee wrote: >> Looks like the problem is that self.entity is the root node and contains >> the subclasses, so attempting to retrieve an attribute by class name >> only works if it is

Re: [sqlalchemy] Re: memory of query cache not release when session close

2015-11-27 Thread Mike Bayer
On 11/27/2015 05:20 AM, Hongxin Song wrote: > In multithreaded scenarios , it is a serious problem , because the > server will be oom that's part of CPython, first see: http://effbot.org/pyfaq/why-doesnt-python-release-the-memory-when-i-delete-a-large-object.htm so once you use 2G of RAM,

Re: [sqlalchemy] sql works when run manually, not when part of sqlalchemy query

2015-11-24 Thread Mike Bayer
no idea. you have any kind of isolated test case? http://stackoverflow.com/help/mcve ? On 11/24/2015 12:17 AM, robert rottermann wrote: > Hi there, > > DB: mysql 5.5.46-0ubuntu0.12.04.2 > Python: 2.7.3 > SQLAlchemy-1.0.9-py2.7-linux-x86_64.egg > > snippet that provokes trace back: >

Re: [sqlalchemy] polymorphic eager loading

2015-11-24 Thread Mike Bayer
I've bisected it down and this one is going to be tough. https://bitbucket.org/zzzeek/sqlalchemy/issues/3593/eager-loading-single-inh-polymorphic-join is added. On 11/24/2015 07:20 PM, Mike Bayer wrote: > > > On 11/24/2015 07:16 PM, Christopher Lee wrote: >> The test passes

Re: [sqlalchemy] polymorphic eager loading

2015-11-24 Thread Mike Bayer
On 11/24/2015 08:19 PM, Mike Bayer wrote: > I've bisected it down and this one is going to be tough. > https://bitbucket.org/zzzeek/sqlalchemy/issues/3593/eager-loading-single-inh-polymorphic-join > is added. I've figured out exactly where a simple thing was going wrong with this and

Re: [sqlalchemy] Pyramid SQLAlchemy tutorial error

2015-11-29 Thread Mike Bayer
On 11/29/2015 09:13 PM, Srikanth Bemineni wrote: > Hi, > > I am going through the Pyramid quick tutorial. > > While initializing the database, I am getting the below error. Can some > one point me out, what would cause this error. I am completely new to > python and pyramid moving here from

Re: [sqlalchemy] Lazier one-to-many relationships

2015-11-29 Thread Mike Bayer
On 11/29/2015 04:52 PM, Daniel Grace wrote: > I'm working on developing an API that, among other things, allows for > partial updates or insertions to a parent's children. One minor problem > that I've found is that any access to parent.children loads the entire > collection -- when in many

Re: [sqlalchemy] Re: memory of query cache not release when session close

2015-11-30 Thread Mike Bayer
On 11/30/2015 06:02 AM, Hongxin Song wrote: > > Although the all rows are paged into memory, they are cached by > identity map for query with loading once。 > Then the total size of memory dose not reduce. > Is that so? > and how can I clear identity-map or close indentity-map pattern?

Re: [sqlalchemy] Re: Pyramid SQLAlchemy tutorial error

2015-11-30 Thread Mike Bayer
On 11/30/2015 09:20 AM, Srikanth Bemineni wrote: > Hi all, > > How do we debug these kind of issues in python ?. The problem was > completely some where else, but error was thrown during database > operation, with no info on the actual issue. it's a dynamic language, so whatever works - we

Re: [sqlalchemy] How to profit from dynamic and eager loading at the same time

2015-11-30 Thread Mike Bayer
On 11/30/2015 07:36 AM, Leily Zafari wrote: > I have two tables "Factorys" and "Products", each "Factory" can have a > large collection of "Products". For appends and filters the dynamic > loading method has been applied. > > | > | > |classFactory(Base): > > __tablename__ ='factorys' >

Re: [sqlalchemy] Subclassing MetaData to Support Higher Level Table-Containing Construct

2015-11-30 Thread Mike Bayer
On 11/30/2015 12:54 PM, Alyssa Kwan wrote: > Hi, > > The problem I'm trying to solve is I've created a multi-temporal > relational table construct (à la bitemporality) that I want to create > SQLAlchemy Core composite operations for (and eventually SQLAlchemy ORM). > > Let's call these

Re: [sqlalchemy] Subclassing MetaData to Support Higher Level Table-Containing Construct

2015-11-30 Thread Mike Bayer
On 11/30/2015 02:29 PM, Alyssa Kwan wrote: > Thanks Michael, > > These constructs are actually composed of 3 tables - the temporal data > itself, a clock table, and an element clock table - both the clocks keep > track of points in time that exist within time ranges since ranges are > lossy.

Re: [sqlalchemy] Subclassing MetaData to Support Higher Level Table-Containing Construct

2015-11-30 Thread Mike Bayer
On 11/30/2015 02:51 PM, Alyssa Kwan wrote: > Thanks, Michael! > > Any thoughts on the autoload? I'd assume you'd want to use a naming convention. e.g. my_autoload('mything') looks for tables 'mything_temporal', 'mything_clock', 'mything_element_clock', something like that. > > Thanks, >

Re: [sqlalchemy] Is there an easy way to get the resulting types from text() query?

2015-11-19 Thread Mike Bayer
On 11/19/2015 12:42 PM, Naveen Michaud-Agrawal wrote: > Ah sorry, I wasn't clearer earlier. The text() call will take an > arbitrary SQL string from the user, so there's no easy way to know which > columns to pass into the .columns() call (short of parsing the statement > and then using

Re: [sqlalchemy] How to make use of bindparam() in a custom Compiled expression?

2015-11-19 Thread Mike Bayer
well what is the ARRAY data you're passing into it? can you provide a complete example? On 11/19/2015 02:04 PM, Юрий Пайков wrote: > The problem is - I can't wrap my head round using it... Could you > direct me to same compiled clause which uses bindparams? > Or perhaps maybe to some

Re: [sqlalchemy] How to make use of bindparam() in a custom Compiled expression?

2015-11-19 Thread Mike Bayer
On 11/19/2015 05:23 PM, Юрий Пайков wrote: > Oh, man I got it. Cannot imagine what kind of an insight hit me when I > figured it out! > Here is a test > case and final version of VALUES clause > > Btw, why there is no _type_api mapping for

Re: [sqlalchemy] Inheritance and self.reference

2015-11-19 Thread Mike Bayer
On 11/19/2015 02:38 PM, Bernhard Radermacher wrote: > I am stumped... > > I have the following scenario: Two classes (Project and Package) inherit > from class Container. Project is at the top-level of the hierarchy, and > can contain Packages, Package must be contained in a Project or a >

Re: [sqlalchemy] How to make use of bindparam() in a custom Compiled expression?

2015-11-19 Thread Mike Bayer
On 11/19/2015 10:07 AM, Юрий Пайков wrote: > But if I used bound parameters in a query - wouldn't it be a solution? > I mean, if a value for a bindparam is not inlined in a query and rather > carried along - there is no need to quote it for the driver, is there? > Like done for any other

Re: [sqlalchemy] Is there an easy way to get the resulting types from text() query?

2015-11-19 Thread Mike Bayer
On 11/19/2015 09:48 AM, Naveen Michaud-Agrawal wrote: > I'm building a small GUI on top of sqlalchemy and would like to change > the alignment of the columns based on the type (string or numeric). This > works fine when the query is generated through query objects (using Mike > Bayer's answer >

Re: [sqlalchemy] Slow response in concurrent threads

2015-11-21 Thread Mike Bayer
if the issue is only with threads and not concurrent processes then the DBAPI in use would be suspect. I don't see which driver you are using but perhaps it is not releasing the GIL while it waits for a server response. I'd identify which driver this is, produce a test case that isolates it

Re: [sqlalchemy] Defining a "First Child" relationship?

2015-11-21 Thread Mike Bayer
On 11/21/2015 09:42 AM, vmalloc wrote: > Hi, > > I'm trying to write a piece of code that would fetch the first event > belonging to an entity, when there might be many events associated: > > | > classEntity(Model): > | > > id = db.Column(db.Integer, primary_key=True) > > events =

Re: [sqlalchemy] (OperationalError) no such column when child class uses different name for primary key in polymorphic relationship and a subselect issued

2015-11-21 Thread Mike Bayer
On 11/20/2015 12:20 PM, Martin Pengelly-Phillips wrote: > Hi there, > > Using SQLAlchemy 1.0.9 > > I am dealing with some legacy code and came across the following issue. > It appears that in a polymorphic relationship SQLAlchemy is not able to > correctly determine what to load for a

Re: [sqlalchemy] PostgreSQL table inheritance with "postgresql_inherits" does not take "add_is_dependent_on" into account

2015-11-23 Thread Mike Bayer
On 11/23/2015 12:43 PM, Adrian wrote: > Hello, > > I have the following problem - I recently upgraded to the 1.0+ branch > from 0.9 and now the PostgreSQL table inheritance does not work properly > any longer because the tables that inherit from the master table are > sometimes created before

Re: [sqlalchemy] Raise exception on implicit join

2015-11-24 Thread Mike Bayer
On 11/24/2015 05:54 AM, Jacob Magnusson wrote: > Thanks for the great answer Michael! I feel a bit ungrateful to make use > of your solution now first, but I had a really stressful period back in > July so I kind of forgot about this. > > I was hoping I could just activate it for all my queries

Re: [sqlalchemy] Adding a condition to an aliased subquery generates a Cartesian product (and incorrect results)

2015-11-19 Thread Mike Bayer
On 11/19/2015 12:38 AM, Laura Pearlman wrote: > Hi, > > When I do this in Python: > > metadata = MetaData() > person = Table('person', metadata, Column('name', String), Column('id', > Integer)) > base_query = select(person.c).alias('person_alias').select() > query =

Re: [sqlalchemy] How to make use of bindparam() in a custom Compiled expression?

2015-11-19 Thread Mike Bayer
On 11/19/2015 05:29 AM, Юрий Пайков wrote: > I based my code on the Michaeil Bayer's answer to this Stack Overflow > question > . > I extended it a little so it takes into account NULLs and ARRAY for > Postgresql. > >

Re: [sqlalchemy] (mysql) dump rows + related objects

2016-01-12 Thread Mike Bayer
if that were me, I'd probably use the ORM to just copy the tables and rows I care about to a blank database, then use mysqldump on that database. dumping is hard, there's lots of formatting and escaping issues that you'd otherwise need to work out on your own. On 01/12/2016 04:17 PM, Sam Raker

Re: [sqlalchemy] custom queries

2016-01-13 Thread Mike Bayer
sure, use pdb to step through and use the "where" command to show where each call originates. alternatively, if this is for profiling, you can use print_callers() as in the example at http://docs.sqlalchemy.org/en/rel_1_0/faq/performance.html#code-profiling which will show the origins of calls,

Re: [sqlalchemy] Eager-load a CTE via relationship or column property

2016-06-03 Thread Mike Bayer
you would first set up a traditional adjacency list relationship as in http://docs.sqlalchemy.org/en/latest/orm/self_referential.html?highlight=adjacency%20list. Second, as you run this query you can retrieve Category objects fully, however they will be in a straight down list. As you

Re: [sqlalchemy] Eager-load a CTE via relationship or column property

2016-06-03 Thread Mike Bayer
On 06/03/2016 11:18 AM, Adrian wrote: I think there's a misunderstanding - I don't want to manually populate the relationship, I want to avoid spamming queries if I get e.g. 10 categories and need the parent chains for all of them. Here's a pseudo-ish example of what I'd like to do (without

Re: [sqlalchemy] sqlalchemy + pyodbc + sybase issue with automap_base().prepare()

2016-06-03 Thread Mike Bayer
) File "C:\brad\anaconda\envs\db-app\lib\site-packages\sqlalchemy\pool.py", line 607, in __connect connection = self.__pool._invoke_creator(self) File "C:\brad\anaconda\envs\db-app\lib\site-packages\sqlalchemy\pool.py", line 285, in

Re: [sqlalchemy] Is there a way to create custom classes that inherit from sqlalchemy models in external library?

2016-06-03 Thread Mike Bayer
On 06/03/2016 02:44 PM, Angie E wrote: Rather than creating mixin classes that models inherit from, I have a use case that requires me to configure classes the other way around. The classes that would normally be mixin classes need to be the classes that inherit from the models as well as the

Re: [sqlalchemy] sqlalchemy + pyodbc + sybase issue with automap_base().prepare()

2016-06-03 Thread Mike Bayer
('IM014', '[IM014] [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Dr iver and Application (0) (SQLDriverConnect)') >>> On Friday, June 3, 2016 at 10:21:18 AM UTC-5, Mike Bayer wrote: On 06/03/2016 11:15 AM, Brad Hud

Re: [sqlalchemy] utf8 error upon insert

2016-06-09 Thread Mike Bayer
valid utf8. That would be your problem. On Thursday, June 9, 2016 at 10:04:49 AM UTC-4, Mike Bayer wrote: On 06/09/2016 09:52 AM, Ven Karri wrote: > I am getting a UTF-8 error upon insert using sql alchemy ORM. The same > query runs fine when I run using raw sql. Her

Re: [sqlalchemy] utf8 error upon insert

2016-06-09 Thread Mike Bayer
yte On Thursday, June 9, 2016 at 10:04:49 AM UTC-4, Mike Bayer wrote: On 06/09/2016 09:52 AM, Ven Karri wrote: > I am getting a UTF-8 error upon insert using sql alchemy ORM. The same > query runs fine when I run using raw

Re: [sqlalchemy] "CompileError: Multiple, unrelated CTEs found with the same name" when using column property

2016-06-09 Thread Mike Bayer
On 06/09/2016 05:39 AM, Adrian wrote: I'm trying to add a `deep_children_count` column property to one of my models. As a regular property it works perfectly fine but I'd like to make it a column property so I don't have to spam extra queries if I need the counts for multiple objects. So I

Re: [sqlalchemy] utf8 error upon insert

2016-06-09 Thread Mike Bayer
5\x99F\x8f' s = Session(e) s.add(A(data=gcm_key)) s.commit() On 06/09/2016 11:16 AM, Ven Karri wrote: The only difference is that I am using sqlalchemy.types.VARBINARY(256) instead of String(255) On Thursday, June 9, 2016 at 10:47:32 AM UTC-4, Mike Bayer wrote: what charset is in your my

Re: [sqlalchemy] sqlalchemy + pyodbc + sybase issue with automap_base().prepare()

2016-06-07 Thread Mike Bayer
rd(self) File "C:\brad\Anaconda3\envs\db-app\lib\site-packages\sqlalchemy\pool.py", line 449, in __init__ self.connection = self.__connect() File "C:\brad\Anaconda3\envs\db-app\lib\site-packages\sqlalchemy\pool.py", line 607, in __connect

Re: [sqlalchemy] sqlalchemy generated query returns fewer objects than rows

2016-06-07 Thread Mike Bayer
On 06/07/2016 03:34 AM, Damian Dimmich wrote: Hi, We've been staring at a problem for some time, where an sqlalchemy generated query we run returns less objects when run with .all() than the number given to us with a .count(). The same, generated query which we get in our logs/from

Re: [sqlalchemy] Flush not working with nested transactions

2016-06-07 Thread Mike Bayer
On 06/07/2016 03:57 AM, Lukas Nabergall wrote: In the unit tests for one module of my app, I'm using the following setup: Any ideas on how to solve this would be greatly appreciated. Perhaps you are using a different session for the query. Here's your code fragment turned into a full

Re: [sqlalchemy] Extend Column Class

2016-06-07 Thread Mike Bayer
Just stick it in the .info dictionary which is designed for this purpose: http://docs.sqlalchemy.org/en/rel_1_0/core/metadata.html?highlight=column.info#sqlalchemy.schema.Column.info subclassing Column is not that easy to do. I wouldn't recommend it. On 06/07/2016 11:50 AM, Charles Heizer

Re: [sqlalchemy] "CompileError: Multiple, unrelated CTEs found with the same name" when using column property

2016-06-10 Thread Mike Bayer
It's probably something small. A bb issue would be targeted at 1.0.x if you want to put one up On Friday, June 10, 2016, Adrian wrote: > Unless there'll be a release fixing this soon-ish: Is there any workaround > that doesn't require patching the sqlalchemy to avoid

Re: [sqlalchemy] utf8 error upon insert

2016-06-09 Thread Mike Bayer
On 06/09/2016 09:52 AM, Ven Karri wrote: I am getting a UTF-8 error upon insert using sql alchemy ORM. The same query runs fine when I run using raw sql. Here's the ORM query: rotating_keys_object = rotating_keys_model( gcm_key=rot_gcm_key, nonce=rot_nonce,

Re: [sqlalchemy] "CompileError: Multiple, unrelated CTEs found with the same name" when using column property

2016-06-09 Thread Mike Bayer
the deannotation step is making a clone of the CTE and not maintaining all the linkages properly. Likely a bug but a really deep one I could use some help on. if you can confirm the query is correct with this patch: diff --git a/lib/sqlalchemy/orm/properties.py

Re: [sqlalchemy] sqlalchemy + pyodbc + sybase issue with automap_base().prepare()

2016-06-03 Thread Mike Bayer
this is supported by just passing all key/value pairs: >>> from sqlalchemy.dialects.sybase import pyodbc >>> dialect = pyodbc.SybaseDialect_pyodbc() >>> from sqlalchemy.engine import url >>> u = url.make_url("sybase+pyodbc:///?user=myuser=mypwd=my.db.server=mydb=FreeTDS=1433_Version=8.0")

Re: [sqlalchemy] How to get unambiguous column name for selectable?

2016-05-25 Thread Mike Bayer
On 05/25/2016 02:25 AM, Andrew Pashkin wrote: On Tuesday, May 24, 2016 at 5:12:32 PM UTC+3, Mike Bayer wrote: q = q.order_by(q.with_labels().statement.c.foo_name) Is that possible to get column objects (or their tables) in the same order as they were joined in Expressions level

Re: [sqlalchemy] How to get unambiguous column name for selectable?

2016-05-25 Thread Mike Bayer
You need to be using join() and not joinedload() here. You shouldn't care about the columns or syntaxes that joinedload() renders. Search the docs for "the zen of eager loading", On Wednesday, May 25, 2016, Andrew Pashkin <andrew.pash...@gmx.co.uk> wrote: > On 05/25/2016 0

Re: [sqlalchemy] How to get unambiguous column name for selectable?

2016-05-25 Thread Mike Bayer
On 05/25/2016 02:15 PM, Andrew Pashkin wrote: On 05/25/2016 08:36 PM, Mike Bayer wrote: You need to be using join() and not joinedload() here. You shouldn't care about the columns or syntaxes that joinedload() renders. Search the docs for "the zen of eager loading", Y

Re: [sqlalchemy] How to get unambiguous column name for selectable?

2016-05-25 Thread Mike Bayer
On 05/25/2016 02:38 PM, Andrew Pashkin wrote: On 05/25/2016 09:28 PM, Mike Bayer wrote: why do you even need this? Basically I have a REST API for which I want to add functionality of filtering and sorting, according to user provided parameters. User supposed to provide a field name

Re: [sqlalchemy] Bug with join?

2016-06-13 Thread Mike Bayer
On 06/13/2016 01:15 PM, Drachenfels wrote: Hi guys, I found very strange behaviour of my script, after a lot of debugging it appears that SQLAlchemy complains about joins that I cannot see exactly why it has any issue with. Full running example is below in both as inline main.py script and

Re: [sqlalchemy] nullable dates

2016-06-14 Thread Mike Bayer
Let's do an MCVE: from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class A(Base): __tablename__ = 'a' id = Column(Integer, primary_key=True) end_date = Column(Date(),nullable=True) e =

Re: [sqlalchemy] How to make escaped column names in sqlalchemy

2016-06-14 Thread Mike Bayer
a column name isn't "escaped", it's quoted. The quoting logic in a compiler goes through compiler.preparer.quote(column.name), if the name needs to be quoted it will come back as such. On 06/14/2016 05:16 AM, Вадим Гухман wrote: Hi, I'm trying to create a small library with utils and

Re: [sqlalchemy] Question about eagerloading and depth of inheritance with respect to polymorphic mappings

2016-06-14 Thread Mike Bayer
On 06/14/2016 11:28 AM, Ken Linehan wrote: Hello, I'm working with a class inheritance structure which can be illustrated by this example: | class Entity(object): def __init__(self, entity_type=EntityTypeEntity, id=None): self.entity_type = entity_type self.id = id

Re: [sqlalchemy] LIKE operator and double percent signs

2016-06-15 Thread Mike Bayer
On 06/15/2016 12:40 PM, Jonathan Rogers wrote: On Friday, February 25, 2011 at 10:27:34 AM UTC-5, Michael Bayer wrote: On Feb 25, 2011, at 10:20 AM, Jon Nelson wrote: > On Fri, Feb 25, 2011 at 9:15 AM, Michael Bayer wrote: >> % is significant in

Re: [sqlalchemy] LIKE operator and double percent signs

2016-06-15 Thread Mike Bayer
On 06/15/2016 01:34 PM, Mike Bayer wrote: On 06/15/2016 12:40 PM, Jonathan Rogers wrote: On Friday, February 25, 2011 at 10:27:34 AM UTC-5, Michael Bayer wrote: On Feb 25, 2011, at 10:20 AM, Jon Nelson wrote: > On Fri, Feb 25, 2011 at 9:15 AM, Michael Bayer &

Re: [sqlalchemy] dealing with NULLS in 1-many relationships

2016-06-06 Thread Mike Bayer
On 06/06/2016 11:21 AM, Horcle wrote: I have the following models: class LabResult(Model): __tablename__ = 'cp_svc_lab_result' id = Column(Integer, primary_key=True, autoincrement=True) test_code = Column(String(255)) test_code_system = Column(String(255)) test_name = Column(String(255))

Re: [sqlalchemy] Re: AttributeError: can't set attribute after updating to 1.0.4 from 0.9.4

2016-05-30 Thread Mike Bayer
On 05/30/2016 04:57 AM, 'Pankaj Gupta' via sqlalchemy wrote: I'm facing exactly same issue. It worked in past very well (below 1.0) and was very useful to update attribute or add new attributes (temporarily), now i can neither update not add new attributes. I'm wondering if someone can help

Re: [sqlalchemy] Re: AttributeError: can't set attribute after updating to 1.0.4 from 0.9.4

2016-05-30 Thread mike bayer
this has been added to the wiki at: https://bitbucket.org/zzzeek/sqlalchemy/wiki/UsageRecipes/WriteableTuple On 05/30/2016 12:21 PM, Mike Bayer wrote: On 05/30/2016 04:57 AM, 'Pankaj Gupta' via sqlalchemy wrote: I'm facing exactly same issue. It worked in past very well (below 1.0

Re: [sqlalchemy] Re: Dealing with large collections in a scaffolded application

2016-05-31 Thread Mike Bayer
you should use "dynamic" and your relationships are mis-configured with mis-use of the backref() construct, as you've constructed relationships on both sides that are mutual you'd use back_populates: class Encounter(Model): patient = relationship( "Patient",

Re: [sqlalchemy] Using sqlalchemy dburi with Oracle using External Password Store (Oracle Wallet)?

2016-05-27 Thread Mike Bayer
get it working with regular cx_oracle first. I'm not familiar with external password store so you should ask on the cx_oracle mailing list (https://sourceforge.net/p/cx-oracle/mailman/cx-oracle-users/) On 05/27/2016 10:18 AM, Matt Vasquez wrote: down votefavorite

Re: [sqlalchemy] Validating appending to collection before other event listeners fire?

2016-05-26 Thread Mike Bayer
On 05/26/2016 11:58 AM, Eric So wrote: Background: I have a two model classes where one is a parent of the other via a one to many relationship. The parent has a collection of the children with a backref: | classParent(base): __tablename__ ="parent_table" parent_key

Re: [sqlalchemy] Using sqlalchemy dburi with Oracle using External Password Store (Oracle Wallet)?

2016-05-27 Thread Mike Bayer
t just fine using the wallet alias: import cx_Oracle db = cx_Oracle.connect("/@PROD") print db.version db.close() I just need to know how to put "/@PROD" in a URI format for sqlalchemy.. On Friday, May 27, 2016 at 9:31:35 AM UTC-5, Mike Bayer wrote: get it working

Re: [sqlalchemy] SQLALchemy 1.0.13: JSONB insert into PostgreSQL fails with internal error 'unsupported jsonb version number 123'

2016-05-31 Thread Mike Bayer
have you tried psycopg2? pypostgresql is not a well supported dialect. On 05/31/2016 07:51 PM, Andrew M wrote: Hi, Thanks for SQLAlchemy. I'm trying to insert some JSONB into a PostgreSQL database. My insert succeeds if the column type is JSON but fails if the type is JSONB. SQLAlchemy

Re: [sqlalchemy] Printing out the schema

2016-06-01 Thread Mike Bayer
On 06/01/2016 02:40 PM, Chase wrote: We have found it useful to be able to print out the schema in SQL to look at it, and to diff versions of it alongside versions of the orm. Printing it out is relatively straightforward, diffing slightly less; currently we're using something very close to

Re: [sqlalchemy] Using CockroachDB with SQLAlchemy

2016-06-01 Thread Mike Bayer
Congratulations on this! I'm pretty excited for NewSQL databases growing in usefulness and popularity. We'd like to have this as part of our list of external dialects at http://docs.sqlalchemy.org/en/latest/dialects/index.html#external-dialects. Currently we have only "production ready"

Re: [sqlalchemy] Re: Dealing with large collections in a scaffolded application

2016-06-01 Thread Mike Bayer
tion: can't locate strategy for (('lazy', 'eager'),) Btw, we rebuilt the database using patient_id as a primary key. Thanks for your help! Greg-- On Tuesday, May 31, 2016 at 3:49:29 PM UTC-5, Mike Bayer wrote: you should use "dynamic" and your relationships are mis-configured with

<    2   3   4   5   6   7   8   9   10   11   >