Thank you so much. Another question: $this->select("col1"); if(1 > 0) { $this->select("col2, col3"); } *$this->from("tbl")->where("1 = 1");* if( 2 > 1) { *$this->where("2 > 1");* } $this->left_outer_join("tbl2", "tbl2.t_id = tbl.id"); // output: SELECT col1, col2, col3 // FROM tbl // LEFT OUTER JOIN tbl2 // ON tbl2.t_id = tbl.id // WHERE 1=1 AND 2 > 1
On sqlalchemy? s = select(["col1"]) if 1 > 0: s.append_column("col2, col3") s.from("tbl") # not found from(...) in sqlalchemy.sql.expression.Select or _SelectBase s.where("1 = 1") if 2 > 1: s.where("2 > 1") s.outerjoin("tbl2", "tbl2.t_id = tbl.id") # not works print s Thank you in advance! On Saturday, August 3, 2013 11:38:48 PM UTC+7, Michael Bayer wrote: > > > On Aug 3, 2013, at 12:34 PM, Taba Taba <beta...@gmail.com <javascript:>> > wrote: > > Hi all, > > I switch from php to python I'm using Codeigniter Query Builder: > > $this->db->select('*'); > $this->db->from('blogs'); > $this->db->join('comments', 'comments.id = blogs.id'); > $this->db->limit(10, 20); > $query = $this->db->get(); > > // Produces: > // SELECT * FROM blogs > // JOIN comments ON comments.id = blogs.id > // LIMIT 20, 10 > > I need model name in string ('blog') not class name (Blog). > > How can i do it with SQLAlchemy? > > > try reading the SQL Expression tutorial: > http://docs.sqlalchemy.org/en/rel_0_8/core/tutorial.html > > > -- 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. For more options, visit https://groups.google.com/groups/opt_out.