[sqlalchemy] colum with server_default does not have new value after session.merge

2013-10-17 Thread Victor Varvariuc
I have a model: class ExchangeRate(Base): ... created_at = Column(DateTime, nullable=False, server_default=func.now()) updated_at = Column(DateTime, nullable=False, server_default=func.now(), server_onupdate=func.now()) Model fields `created_at` and

[sqlalchemy] Re: colum with server_default does not have new value after session.merge

2013-10-17 Thread Victor Varvariuc
Not sure if this matters, but the model doesn't have an autoincrement primary key: class ExchangeRate(Base): currency_from = Column(CURRENCY_ISO_CODE_TYPE, primary_key=True) currency_to = Column(CURRENCY_ISO_CODE_TYPE, primary_key=True) ... created_at = Column(DateTime,

Re: [sqlalchemy] Joining two subqueries doesn't return the expected result (object)

2013-10-17 Thread Michael Bayer
On Oct 17, 2013, at 1:48 AM, Christoph Reisbach christoph.reisb...@gmail.com wrote: existing_query = session.query(TableOne).subquery() additional_query = session.query(TableTwo).subquery() combined_query = session.query(existing_query).join(additional_query) print

Re: [sqlalchemy] colum with server_default does not have new value after session.merge

2013-10-17 Thread Michael Bayer
On Oct 17, 2013, at 6:34 AM, Victor Varvariuc victor.varvar...@gmail.com wrote: I have a model: class ExchangeRate(Base): ... created_at = Column(DateTime, nullable=False, server_default=func.now()) updated_at = Column(DateTime, nullable=False, server_default=func.now(),

Re: [sqlalchemy] Joining two subqueries doesn't return the expected result (object)

2013-10-17 Thread Chris
They both have to be subqueries because they can have where-statements. If select_from() is the normal way than I have to live with these additional select-from-constructions. Do you have/know some example of how to use from_statement()? Because I tried it with from_statement() but it doesn't

Re: [sqlalchemy] Re: most established SQLA fixture tools?

2013-10-17 Thread Iain Duncan
Thanks Jonathan, Alembic has been on my to-check-out list for a while. Does anyone here use it for test db population? I'm honestly not seeing the big advantage of populating from json files, but I suppose there must be some. At any rate I have them from a previous project the same client has

Re: [sqlalchemy] colum with server_default does not have new value after session.merge

2013-10-17 Thread Michael Bayer
On Oct 17, 2013, at 10:34 AM, Victor Varvariuc victor.varvar...@gmail.com wrote: Ok, so the answer is to use 'eager_defaults': True : class CommonBase(object): Base model for Apilib db-mapped and virtual models. __mapper_args__ = { # immediately fetch the value of

[sqlalchemy] Returning multiple table models on join query instead of keyed tuple

2013-10-17 Thread John Kida
I am trying find a nice automatic way to serialize my sql alchemy result sets when doing joins. Lets say i have the following 2 models, User and Message: class User(Base): __tablename__ = '...' id = Column(...) name = Column(...) last_login Column(...) and class Message(Base):

Re: [sqlalchemy] Joining two subqueries doesn't return the expected result (object)

2013-10-17 Thread Michael Bayer
On Oct 17, 2013, at 11:21 AM, Chris christoph.reisb...@gmail.com wrote: They both have to be subqueries because they can have where-statements. If select_from() is the normal way than I have to live with these additional select-from-constructions. Do you have/know some example of how to

[sqlalchemy] Adding a trigger

2013-10-17 Thread Joseph Casale
I have a module I import which has some table defs and global sessionmaker() instance. If the module is ran directly, it executes a create_all() to build a new db. I am trying to add a trigger DDL event listener: trg = DDL('...') event.listen( SomeName.__table__, 'after_create',

Re: [sqlalchemy] Returning multiple table models on join query instead of keyed tuple

2013-10-17 Thread Michael Bayer
On Oct 17, 2013, at 12:51 PM, John Kida jdk...@gmail.com wrote: I am trying find a nice automatic way to serialize my sql alchemy result sets when doing joins. Lets say i have the following 2 models, User and Message: class User(Base): __tablename__ = '...' id = Column(...)

Re: [sqlalchemy] Adding a trigger

2013-10-17 Thread Michael Bayer
On Oct 17, 2013, at 1:13 PM, Joseph Casale jcas...@gmail.com wrote: I have a module I import which has some table defs and global sessionmaker() instance. If the module is ran directly, it executes a create_all() to build a new db. I am trying to add a trigger DDL event listener: trg =

Re: [sqlalchemy] Re: most established SQLA fixture tools?

2013-10-17 Thread Jonathan Vanasco
I don't , but should. I've just used database dumps and a homebrew system, because tools like this didn't exist when I first needed them. BUT it seems to offer the same functionality as Rails/Django migrations , which you will eventually need in your new Django-favoring environment. -- You

Re: [sqlalchemy] colum with server_default does not have new value after session.merge

2013-10-17 Thread Victor Varvariuc
I am using sqla 0.8 On Oct 17, 2013 8:46 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Oct 17, 2013, at 10:34 AM, Victor Varvariuc victor.varvar...@gmail.com wrote: Ok, so the answer is to use 'eager_defaults': True : class CommonBase(object): Base model for Apilib db-mapped

Re: [sqlalchemy] Returning multiple table models on join query instead of keyed tuple

2013-10-17 Thread John Kida
The Bundle option sounds perfect, there is really no need for the other attrs to be None, i was just trying to explain the idea. Is there a nightly avaliable of 0.9 that I can grab that has a partially working version of Bundle? -- You received this message because you are subscribed to the

Re: [sqlalchemy] colum with server_default does not have new value after session.merge

2013-10-17 Thread Michael Bayer
eager_defaults wasn't much of an option until 0.9, might have to work around that issue for now. On Oct 17, 2013, at 2:23 PM, Victor Varvariuc victor.varvar...@gmail.com wrote: I am using sqla 0.8 On Oct 17, 2013 8:46 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Oct 17, 2013,

Re: [sqlalchemy] Returning multiple table models on join query instead of keyed tuple

2013-10-17 Thread Michael Bayer
its totally working, just grab 0.9 from github. On Oct 17, 2013, at 2:35 PM, John Kida jdk...@gmail.com wrote: The Bundle option sounds perfect, there is really no need for the other attrs to be None, i was just trying to explain the idea. Is there a nightly avaliable of 0.9 that I can

Re: [sqlalchemy] Adding a trigger

2013-10-17 Thread Joseph Casale
you need to pass a Python callable function (def or lambda, typically) to event.listen, which it will call when the event occurs. right now you're just running the execute() before the listen() is even called: event.listen(table, after_create, lambda *args: trg.execute(bind=engine))

[sqlalchemy] sqlite and two serious question

2013-10-17 Thread Mohsen Pahlevanzadeh
Dear all, I migrated from mysql to sqlite for a tablet project, i made my tables and work fine with mysql, but dont' work with sqlite, My question are: 1. hwo can i input utf8 in sqlite? 2. how can input date data type in sqlite? -- You received this message because you are subscribed to