]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
add an interesting from_statement() format
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 21 Nov 2009 20:51:16 +0000 (20:51 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 21 Nov 2009 20:51:16 +0000 (20:51 +0000)
doc/build/ormtutorial.rst

index b1f647e51b5f4c5e81229a19a0c3bfd2421f37a1..d23834c0dbc62ed6f79fdf32267af9a0a5ea3903 100644 (file)
@@ -581,6 +581,15 @@ To use an entirely string-based statement, using ``from_statement()``; just ensu
     ['ed']
     {stop}[<User('ed','Ed Jones', 'f8s7ccs')>]
 
+You can use ``from_statement()`` to go completely "raw", using string names to identify desired columns:
+
+.. sourcecode:: python+sql
+
+    {sql}>>> session.query("id", "name", "thenumber12").from_statement("SELECT id, name, 12 as thenumber12 FROM users where name=:name").params(name='ed').all()
+    SELECT id, name, 12 as thenumber12 FROM users where name=?
+    ['ed']
+    {stop}[(1, u'ed', 12)]
+
 Counting
 --------