[sqlalchemy] Tracking new relationships

2017-11-30 Thread Tolstov Sergey
Hi, everyone. I cannot found information how to find information about new relationships, when they related with secondary table. Inspect can't work with class RelationshipProperty. class_mapper.iterate_properties have't information about changed attributes My *task* is: Write transactio

[sqlalchemy] Writing a Table that changes its schema and name if ii's used with PostgreSQL or Oracle

2017-11-30 Thread Massimiliano della Rovere
Greetings, I'm writing to ask some hints for my problem. I am using SQLAlchemy Core (no ORM, because everything it is wrapped by sqlachemy_aio - everything happens inside a asyncio loop). The program I'm working on can be deployed with a PostgreSQL or an Oracle DB, customer choice, I have no po

Re: [sqlalchemy] Replace relationship values with join() call

2017-11-30 Thread Анатолий Иванов
Hi Mike! Thanks for answering. In fact i tried that same code as you posted and it did eager load of original (not my subquery) data. However, here i found a mention that contains_eager has an alias parameter, so doing s.query(A).join

Re: [sqlalchemy] Oracle Boolean Attribute - SQL command not properly ended

2017-11-30 Thread Kevin Foley
Would using not_ be the appropriate way to get non current addresses? On Thursday, November 30, 2017 at 1:22:56 PM UTC-5, Kevin Foley wrote: > > Ah I see, I was using q = > s.query(A.is_current_address).filter(A.is_current_address==True), just > using A.is_current_address produces the same resu

Re: [sqlalchemy] Oracle Boolean Attribute - SQL command not properly ended

2017-11-30 Thread Kevin Foley
Ah I see, I was using q = s.query(A.is_current_address).filter(A.is_current_address==True), just using A.is_current_address produces the same results you have. Thanks! On Thursday, November 30, 2017 at 12:49:37 PM UTC-5, Mike Bayer wrote: > > On Thu, Nov 30, 2017 at 10:31 AM, Kevin Foley > wr

Re: [sqlalchemy] Oracle Boolean Attribute - SQL command not properly ended

2017-11-30 Thread Mike Bayer
On Thu, Nov 30, 2017 at 10:31 AM, Kevin Foley wrote: > I created a Boolean attribute for an Oracle table that checks if an address > is the customer's current address. > > @is_current_address.expression > def is_current_address(cls): > return and_(cls.eff_date <= func.current_date(), cls.t

[sqlalchemy] Re: Dictionaries with mapped objects as keys and integers as values

2017-11-30 Thread Sven
It works admirably well. Again, thank you very much for the support you provide. -- 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.

[sqlalchemy] Oracle Boolean Attribute - SQL command not properly ended

2017-11-30 Thread Kevin Foley
I created a Boolean attribute for an Oracle table that checks if an address is the customer's current address. @is_current_address.expression def is_current_address(cls): return and_(cls.eff_date <= func.current_date(), cls.term_date >= func.current_date()) When I try to run a query wit

Re: [sqlalchemy] Replace relationship values with join() call

2017-11-30 Thread Mike Bayer
On Thu, Nov 30, 2017 at 8:41 AM, Анатолий Иванов wrote: > Hello everyone! > > > TL;DR: > A mapping (class A) has a relationship(to class B). Lazy load is specified. > I want to > > manually select and filter data from B (the result lets call B') > select everything from A > outer join A with B' >

Re: [sqlalchemy] Influencing what CREATE statement generated in sqlalchemy

2017-11-30 Thread Mike Bayer
On Thu, Nov 30, 2017 at 5:32 AM, su-sa wrote: > Hi everyone, > > does someone maybe know if one can from the dialect somehow influence what > CREATE TABLE statement would be generated in certain cases? > > So for example: In the tests for temporary table I saw that for Oracle, the > create table s

[sqlalchemy] Re: Replace relationship values with join() call

2017-11-30 Thread Анатолий Иванов
association_table is not needed here, forgot to remove it, when minimizing the code, sorry. On Thursday, 30 November 2017 16:41:05 UTC+3, Анатолий Иванов wrote: > > Hello everyone! > > > *TL;DR:* > A mapping (class A) has a relationship(to class B). Lazy load is > specified. I want to > >1.

[sqlalchemy] Replace relationship values with join() call

2017-11-30 Thread Анатолий Иванов
Hello everyone! *TL;DR:* A mapping (class A) has a relationship(to class B). Lazy load is specified. I want to 1. manually select and filter data from B (the result lets call B') 2. select everything from A 3. outer join A with B' Problem: when doing all_b = session.query(B).filter

Re: [sqlalchemy] Possible Exceptions

2017-11-30 Thread Lars Liedtke (SCC)
Am 29.11.2017 um 17:16 schrieb Mike Bayer: > On Wed, Nov 29, 2017 at 11:12 AM, Mike Bayer wrote: >> On Wed, Nov 29, 2017 at 3:37 AM, wrote: >>> Hello everybody, >>> >>> I am writing some piece of code, which should not exit unforseen in the best >>> case, at least it should write to a log file

[sqlalchemy] Influencing what CREATE statement generated in sqlalchemy

2017-11-30 Thread su-sa
Hi everyone, does someone maybe know if one can from the dialect somehow influence what CREATE TABLE statement would be generated in certain cases? So for example: In the tests for temporary table I saw that for Oracle, the create table statement has been adjusted, but that only ís a hack to m