I wanna perform a query on process_files and hereafter a update/join like this:
SELECT files.id AS files_id, files.name AS files_name, files.directory AS files_directory, files.active AS files_active, files.connection_id AS files_connection_id FROM files JOIN process_files ON files.id = process_files.files_id Actually the piece os select above is a result from: result = session.query(Files).join(process_files) It is ok, but i wanna filter it with process_files.process_id = 1 for example. Reading the docs i could not find the proper way to do this: http://docs.sqlalchemy.org/en/rel_0_7/orm/query.html#sqlalchemy.orm.query.Query.join Am i reading the wrong part of the docs? 2013/3/7 Mauricio de Abreu Antunes <mauricio.abr...@gmail.com> > These tips are veeery good! > I sometimes get lost about the best way to use the best ORM library in the > world. > > > 2013/3/7 Simon King <si...@simonking.org.uk> > >> This is an unusual way to update an object that you've already retrieved: >> >> result = session.query(Executions). \ >> filter_by(id=execution_id).first() >> if result.end_date is None: >> e = >> update(Executions).where(Executions.id==bindparam("execution_id")). \ >> values(end_date=bindparam("now")) >> self.connection.execute(e, execution_id=execution_id, >> now=datetime.datetime.now()) >> >> It would be more natural to write it like this: >> >> if result.end_date is None: >> result.end_date = datetime.datetime.now() >> session.flush() >> >> Also, if "id" is the primary key on your Executions class, you can >> write the first line as: >> >> result = session.query(Executions).get(execution_id) >> >> >> On Thu, Mar 7, 2013 at 1:58 AM, Michael Bayer <mike...@zzzcomputing.com> >> wrote: >> > in the 0.7 series, you can't pass an ORM mapped class as the subject of >> the >> > core update() construct: >> > >> > e = update(Executions).where(Executions.id==bindparam("execution_id")). >> \ >> > values(end_date=bindparam("now")) >> > >> > that statement will work as is if you just refer to the Table: >> > >> > e = >> > >> update(Executions.__table__).where(Executions.id==bindparam("execution_id")). >> > \ >> > values(end_date=bindparam("now")) >> > >> > also note that the indirection between bindparam("foo") and >> > connection.execute(stmt, foo="some value") is not needed; you can embed >> > literal values directly in the statement, and the Core will convert >> them to >> > bound parameters (just use echo=True to see it in action): >> > >> > e = update(Executions).where(Executions.id==execution_id). \ >> > values(end_date=datetime.datetime.now()) >> > >> > At the ORM level, you can use query.update(): >> > >> > >> session.query(Executions).filter(Executions.id==execution_id).update({"end_date":datetime.now()}, >> > synchronize_session=False) >> > >> > >> > On Mar 6, 2013, at 8:06 PM, Mauricio de Abreu Antunes >> > <mauricio.abr...@gmail.com> wrote: >> > >> > So, i have read @StackOverflow some tips. >> > There is a lot of people saying they have to make a query on the table >> and >> > then update it. there is no way to upgrade without performing a query?! >> > >> > On Wednesday, March 6, 2013 6:17:35 PM UTC-3, Mauricio de Abreu Antunes >> > wrote: >> >> >> >> Hello, >> >> >> >> I'm new to SQLAlchemy. Currently I'm using SQLAlchemy 0.7.1. >> >> Reading the tutorial, I tried to write my codes like those examples >> but I >> >> had no success working on it. >> >> >> >> Code is here: >> >> https://gist.github.com/mauricioabreu/5103163 >> >> >> >> Do I need to map the table Executions to execute an update expression >> on >> >> it? >> >> >> >> Sorry if this is a very noob question. >> >> >> >> If you need more info about the problem let me know. >> > >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups >> > "sqlalchemy" group. >> > To unsubscribe from this group and stop receiving emails from it, send >> an >> > email to sqlalchemy+unsubscr...@googlegroups.com. >> > To post to this group, send email to sqlalchemy@googlegroups.com. >> > Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. >> > For more options, visit https://groups.google.com/groups/opt_out. >> > >> > >> > >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups >> > "sqlalchemy" group. >> > To unsubscribe from this group and stop receiving emails from it, send >> an >> > email to sqlalchemy+unsubscr...@googlegroups.com. >> > To post to this group, send email to sqlalchemy@googlegroups.com. >> > Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. >> > For more options, visit https://groups.google.com/groups/opt_out. >> > >> > >> >> -- >> You received this message because you are subscribed to the Google Groups >> "sqlalchemy" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to sqlalchemy+unsubscr...@googlegroups.com. >> To post to this group, send email to sqlalchemy@googlegroups.com. >> Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > > -- > *Mauricio de Abreu Antunes* > Mobile: (51)930-74-525 > Skype: mauricio.abreua > -- *Mauricio de Abreu Antunes* Mobile: (51)930-74-525 Skype: mauricio.abreua -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.