[sqlalchemy] is True vs ==True

2015-03-30 Thread Jose Soares
Hi all, While I changed some obsolete syntax as defined in (https://www.python.org/dev/peps/pep-0008/) like (is True instead of ==True) also False and None. I realized that sqlalchemy do not support them What can I do to avoid this behavior?

Re: [sqlalchemy] How to add custom attribute to the session?

2015-03-30 Thread Simon King
On Mon, Mar 30, 2015 at 1:09 PM, uralbash svintso...@gmail.com wrote: Hello, I want to set up in each session was my custom attribute, for example: from sqlalchemy.orm import scoped_session, sessionmaker Session = my_wapper(scoped_session(sessionmaker())) session1 = Session() session2 =

Re: [sqlalchemy] How to add custom attribute to the session?

2015-03-30 Thread uralbash
More example in tests https://github.com/ITCase/sacrud/blob/master/sacrud/tests/test_sessionmaker.py def test_create(self): user = self.session.sacrud(User)\ .create({'name': 'Dzhirad', 'fullname': 'Kiri', 'password': 123}) self.assertEqual(user.name, 'Dzhirad')

Re: [sqlalchemy] is True vs ==True

2015-03-30 Thread Jose Soares
Hmm! in this case we must distinguish between the python syntax and the sqlalchemy syntax.:-( j On 30/03/2015 12:37, Simon King wrote: On Mon, Mar 30, 2015 at 10:59 AM, Jose Soares jose.soa...@sferacarta.com wrote: Hi all, While I changed some obsolete syntax as defined in

Re: [sqlalchemy] How to add custom attribute to the session?

2015-03-30 Thread uralbash
I'm writing a module (sacrud https://github.com/ITCase/sacrud) that is not initially aware of the session. I want to add my session method (sacrud). from sqlalchemy.orm import scoped_session, sessionmaker from sacrud import crud_sessionmaker DBSession =

Re: [sqlalchemy] is True vs ==True

2015-03-30 Thread Richard Gerd Kuesters | Pollux
there's this: * import sqlalchemy as sa** ** sa.sql.null()** **sqlalchemy.sql.elements.Null object at 0x7f8a70065c50** ** sa.sql.false()** **sqlalchemy.sql.elements.False_ object at 0x7f8a6fb13050** ** sa.sql.true()** **sqlalchemy.sql.elements.True_ object at 0x7f8a70065c50** * so, you can still

[sqlalchemy] Inherited class column override

2015-03-30 Thread Pierre B
Hi all, I'm ultimately trying to have different default values for the same column. Following the documentation, the @declared_attr.cacading decorator seems to be the best approach. Here's my code: class HasSomeAttribute(object): @declared_attr.cascading def type(cls): if

Re: [sqlalchemy] is True vs ==True

2015-03-30 Thread Simon King
On Mon, Mar 30, 2015 at 10:59 AM, Jose Soares jose.soa...@sferacarta.com wrote: Hi all, While I changed some obsolete syntax as defined in (https://www.python.org/dev/peps/pep-0008/) like (is True instead of ==True) also False and None. I realized that sqlalchemy do not support them What

[sqlalchemy] How to add custom attribute to the session?

2015-03-30 Thread uralbash
Hello, I want to set up in each session was my custom attribute, for example: from sqlalchemy.orm import scoped_session, sessionmaker Session = my_wapper(scoped_session(sessionmaker())) session1 = Session() session2 = Session() hasattr(session1, foo) # True: What I want hasattr(session2, foo)

Re: [sqlalchemy] is True vs ==True

2015-03-30 Thread Mathieu Leduc-Hamel
why not just called it that way: filter(Rischio.c.peso_gruppo.is_(True)) And it would be the same thing for None and False And the opposite would be: filter(not_(Rischio.c.peso_gruppo.is_(None))) Le lun. 30 mars 2015 à 11:10, Jonathan Vanasco jonat...@findmeon.com a écrit : If

Re: [sqlalchemy] is True vs ==True

2015-03-30 Thread Jose Soares
Yeah, this is a good solution. Thanks for the tip. j On 30/03/2015 16:33, Richard Gerd Kuesters | Pollux wrote: there's this: * import sqlalchemy as sa** ** sa.sql.null()** **sqlalchemy.sql.elements.Null object at 0x7f8a70065c50** ** sa.sql.false()** **sqlalchemy.sql.elements.False_ object at

Re: [sqlalchemy] Inherited class column override

2015-03-30 Thread Michael Bayer
Pierre B rocambolesque...@gmail.com wrote: Hi all, I'm ultimately trying to have different default values for the same column. Following the documentation, the @declared_attr.cacading decorator seems to be the best approach. Here's my code: class HasSomeAttribute(object):

Re: [sqlalchemy] How to add custom attribute to the session?

2015-03-30 Thread Simon King
Can't you write it like this (untested)? # class CRUDSession(sqlalchemy.orm.Session): def sacrud(self, cls): return CRUD(self, cls) Session = scoped_session(sessionmaker(class_=CRUDSession)) # Simon On Mon, Mar 30, 2015 at 3:15 PM, uralbash svintso...@gmail.com wrote: More

Re: [sqlalchemy] is True vs ==True

2015-03-30 Thread Jonathan Vanasco
If you're just worried about warnings in Flake8, you can turn them off line-by-line: filter( Rischio.c.peso_gruppo == True # noqa )\ -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop

Re: [sqlalchemy] How to add custom attribute to the session?

2015-03-30 Thread uralbash
Yes, it works. Thank you so much. понедельник, 30 марта 2015 г., 19:58:40 UTC+5 пользователь Simon King написал: Can't you write it like this (untested)? # class CRUDSession(sqlalchemy.orm.Session): def sacrud(self, cls): return CRUD(self, cls) Session =

[sqlalchemy] is it possible to turn off DELETE cascades globally for a session?

2015-03-30 Thread Jonathan Vanasco
I'm running a migration script, and the deletes via the ORM were creating a performance issue. (trying to load 4 relationships 9million times adds up) I couldn't find any docs for this (just some references on update cascades) so i sidestepped the issue by just running the Engine's delete on

[sqlalchemy] Re: Is there any potential problem to store datetime as strings in one column?

2015-03-30 Thread Bao Niu
On Monday, March 23, 2015 at 7:53:31 AM UTC-7, Jonathan Vanasco wrote: On Sunday, March 22, 2015 at 7:01:35 PM UTC-4, Bao Niu wrote: Also because sql datetime datatype doesn't persist timezone information. Therefore, I tried to store all the time information as strings. If your

[sqlalchemy] Re: Is there any potential problem to store datetime as strings in one column?

2015-03-30 Thread Jonathan Vanasco
On Monday, March 30, 2015 at 9:06:48 PM UTC-4, Bao Niu wrote: To make sure that I understand it right, did you mean hybrid attribute methods when you mentioned property methods here? Thanks No, just simple property methods. A super-simple first Minimum Viable Product/iteration might be:

[sqlalchemy] Custom Type - two classes (object + TypeDecorator) or one (TypeDecorator)?

2015-03-30 Thread Jeffrey McLarty
Hello, First - amazing work on SQLAlchemy, what an amazing body of work. Second, my question. I'm attempting to convert a pure-python object, into a custom type for column definition. My question is, do I need to keep my original MyObj(object) and use it inside the

Re: [sqlalchemy] is it possible to turn off DELETE cascades globally for a session?

2015-03-30 Thread Michael Bayer
it’s not an option available at the moment, though there might be ways to avoid the collection loads (artificially zeroing them out w/o history). if you don’t need the relationship features then you might as well just use query.delete(). Jonathan Vanasco jonat...@findmeon.com wrote: I'm