[sqlalchemy] Can I make an update over a table that comes from sqlalchemy.MetaData(...).reflect()?

2015-03-12 Thread Nelson Castillo
Hi there. I have searched but I haven't found an answer to my issue. I have this code: metadata = sqlalchemy.MetaData(bind=self.engine) metadata.reflect() table_user = self.metadata.tables['USER'] Now, how can I issue a SQL update over the table table_user (using the variable

Re: [sqlalchemy] duplicate an object

2015-03-12 Thread Michael Bayer
moon...@posteo.org wrote: On 2015-03-08 11:17 Michael Bayer mike...@zzzcomputing.com wrote: there’s no particular “SQLAlchemy way” to do this, What is about make_transient() ? I don't understand this function 100%tly. it changes the state of an object from persistent to

Re: [sqlalchemy] relationship problem

2015-03-12 Thread Michael Bayer
Julien Cigar jci...@ulb.ac.be wrote: Hi Mike, Sorry to bother you once with this, but I've re-read all the docs on the relationships and I want to be sure that I've understand correctly. Imagine I have the following link table in SQL:

Re: [sqlalchemy] duplicate an object

2015-03-12 Thread Michael Bayer
moon...@posteo.org wrote: On 2015-03-08 11:17 Michael Bayer mike...@zzzcomputing.com wrote: new_obj = MyClass() for attr in mapper.attrs: setattr(new_obj, attr.key, getattr(old_obj, attr.key)) This would copy everything including primary keys and unique members. which is why, “copy

[sqlalchemy] postgres schemas at runtime

2015-03-12 Thread Francesco Della Vedova
Hello, I have a set of models that I would like to replicate on different Postgres schemas. The name of the schema is only known at runtime. Just as an example, imagine I have a bunch of tables of customer data, and I want to create a schema 'customer_id' with the same tables every time I

Re: [sqlalchemy] postgres schemas at runtime

2015-03-12 Thread Michael Bayer
Francesco Della Vedova francesco.dellaved...@rocket-internet.de wrote: Hello, I have a set of models that I would like to replicate on different Postgres schemas. The name of the schema is only known at runtime. Just as an example, imagine I have a bunch of tables of customer data, and

Re: [sqlalchemy] postgres schemas at runtime

2015-03-12 Thread Francesco Della Vedova
I thought about wrapping create_all this way: def create_tables(database, schema=None): for table in Base.metadata.tables.values(): table.schema = schema Base.metadata.create_all(database.engine) and then probably use the event for all the queries afterwards. Is this too much of

Re: [sqlalchemy] Can I make an update over a table that comes from sqlalchemy.MetaData(...).reflect()?

2015-03-12 Thread Simon King
On Wed, Mar 11, 2015 at 10:12 AM, Nelson Castillo nelson...@gmail.com wrote: Hi there. I have searched but I haven't found an answer to my issue. I have this code: metadata = sqlalchemy.MetaData(bind=self.engine) metadata.reflect() table_user = self.metadata.tables['USER'] Now,

Re: [sqlalchemy] relationship problem

2015-03-12 Thread Julien Cigar
On Mon, Mar 02, 2015 at 12:15:51PM -0500, Michael Bayer wrote: Julien Cigar jci...@ulb.ac.be wrote: On Sun, Mar 01, 2015 at 01:53:30PM +0100, Julien Cigar wrote: On Fri, Feb 27, 2015 at 11:38:05PM -0500, Michael Bayer wrote: On Feb 26, 2015, at 5:56 AM, Julien Cigar jci...@ulb.ac.be