[sqlalchemy] many-to-many relation: unexpected count of rows

2015-03-05 Thread Pavel S
Hello, I have relation User-User2Group-Group with additional attribute System on User2Group table. The System is part of primary key, which means *'user can me member of group via multiple systems'.* class User(Base): __tablename__ = 'User' name = Column('Name', Unicode(256),

[sqlalchemy] Re: many-to-many relation: unexpected count of rows

2015-03-05 Thread Pavel S
Hi, Adding viewonly=True on User.groups relationship solved the issue. cheers! Dne čtvrtek 5. března 2015 11:26:58 UTC+1 Pavel S napsal(a): Hello, I have relation User-User2Group-Group with additional attribute System on User2Group table. The System is part of primary key, which means

Re: [sqlalchemy] Re: many-to-many relation: unexpected count of rows

2015-03-05 Thread Pavel S
-association-objects Hope that helps, Simon On Thu, Mar 5, 2015 at 10:43 AM, Pavel S pa...@schon.cz javascript: wrote: Hi, Adding viewonly=True on User.groups relationship solved the issue. cheers! Dne čtvrtek 5. března 2015 11:26:58 UTC+1 Pavel S napsal(a): Hello

Re: [sqlalchemy] Re: many-to-many relation: unexpected count of rows

2015-03-05 Thread Pavel S
, the UserKeyword's user property is not set explicitly, but because of the backref on User.user_keywords, appending to the list will cause the user property to be assigned. Simon On Thu, Mar 5, 2015 at 11:46 AM, Pavel S pa...@schon.cz javascript: wrote: Hi, I just noticed

Re: [sqlalchemy] SQLAlchemy as plain-SQL generator

2015-04-22 Thread Pavel S
metadata, so sqlalchemy can write the right sql for you. also, your query should be a *select()* object, like your example. this worked for me for some time, using SA 0.9, i don't know about 1.0, but it should work too. cheers, richard. On 04/22/2015 04:26 AM, Pavel S wrote: Hello

Re: [sqlalchemy] SQLAlchemy as plain-SQL generator

2015-04-22 Thread Pavel S
time, using SA 0.9, i don't know about 1.0, but it should work too. cheers, richard. On 04/22/2015 04:26 AM, Pavel S wrote: Hello, I have pythonic application which imports custom module written in C++ using boost::python. The module creates database connection(s) and executes

[sqlalchemy] SAWarning: Unicode type received non-unicode bind param value

2015-04-22 Thread Pavel S
Hi, it happened to me many times during development, mainly when used custom column types, that I passed wrong type of value to the query. Then the the following warning was emitted: SAWarning: Unicode type received non-unicode bindparam value The problem with such warning is it does not say

[sqlalchemy] SQLAlchemy as plain-SQL generator

2015-04-22 Thread Pavel S
Hello, I have pythonic application which imports custom module written in C++ using boost::python. The module creates database connection(s) and executes queries. The python calls various methods on that module and passes plain SQL into them. Results are then returned to python. I would like

Re: [sqlalchemy] SAWarning: Unicode type received non-unicode bind param value

2015-04-22 Thread Pavel S
, you dan do: import warnings warnings.simplefilter('error') This will raise an exception. and give you a stacktrace on where the Unicode warnign happened. On 04/22/2015 09:48 AM, Pavel S wrote: Hi, it happened to me many times during development, mainly when used custom

[sqlalchemy] Re: func.substr() documentation?

2015-08-03 Thread Pavel S
You should refer documentation of your RDBMS. '*func*' is just proxy to any function defined inside RDBMS. If your RDBMS has function *bla* (e.g. CREATE FUNCTION bla...), then you can call if from python using *func.bla()*. Dne neděle 2. srpna 2015 19:12:04 UTC+2 c.b...@posteo.jp napsal(a):

[sqlalchemy] onupdate with ORM

2015-09-04 Thread Pavel S
Hi, I have declarative Model with couple of columns, one of them is lastAccess = Column('LastAccess', DateTime, nullable=False, onupdate=datetime.datetime.utcnow) I fetch the object from database like the following: obj = ScopedSession.query(Model).get(something) Later in code I commit the

Re: [sqlalchemy] ORM: walk() related objects

2015-09-10 Thread Pavel S
Hi Michael, this is amazing, thanks!!! On Thursday, September 10, 2015 at 3:35:39 PM UTC+2, Michael Bayer wrote: > > > > On 9/10/15 8:48 AM, Pavel S wrote: > > Let's say, I have declarative classes A, B, C, D. > > A is the parent > B has FK to A > C has FK to B,

[sqlalchemy] ORM: walk() related objects

2015-09-10 Thread Pavel S
Let's say, I have declarative classes A, B, C, D. A is the parent B has FK to A C has FK to B, D has FK to C etc... I'd like to implement *generic method* walk(obj) which will recursively yield dependent/related objects of obj (which is instance of A). I know that there is introspection

Re: [sqlalchemy] ORM: walk() related objects

2015-09-10 Thread Pavel S
elif related is not None: for walk_related in walk(related, level + 1, memo): yield walk_related On Thursday, September 10, 2015 at 3:48:55 PM UTC+2, Michael Bayer wrote: > > > > On 9/10/15 9:35 AM, Mike Bayer wrote: > > > > On

Re: [sqlalchemy] ORM: walk() related objects

2015-09-15 Thread Pavel S
pondělí 14. září 2015 11:57:05 UTC+2 Pavel S napsal(a): > > Hi, > > I just realized that I need your first solution, since I need to get only > those objects that would cascade in case of deletion. > > But thanks anyhow... > > P > > Dne čtvrtek 10. září 2015 15

Re: [sqlalchemy] ORM: walk() related objects

2015-09-14 Thread Pavel S
Hi, I just realized that I need your first solution, since I need to get only those objects that would cascade in case of deletion. But thanks anyhow... P Dne čtvrtek 10. září 2015 15:35:39 UTC+2 Michael Bayer napsal(a): > > > > On 9/10/15 8:48 AM, Pavel S wrote: > >

[sqlalchemy] unregister Tables from Metadata

2015-10-01 Thread Pavel S
Hi, we use application-level partitioning (but no real partitioning in mysqld), where new tables are created daily with the same structure, but different name (suffix). - mysqld is shared for these components: - daemon written in C++ - creates new tables every day and fills

[sqlalchemy] Debugging complex SQLAlchemy applications

2017-07-11 Thread Pavel S
Hi, I maintain extremely complex application (>100k LOC) which uses SQLAlchemy. Often in the log I find errors like: sqlalchemy/engine/default.py:450: Warning: Truncated incorrect DOUBLE value: 'Foo' or sqlalchemy/sql/sqltypes.py:201: SAWarning: Unicode type received non-unicode bind param