[Sqlalchemy-commits] [1529] sqlalchemy/trunk/doc/build/content/sqlconstruction.txt: formatting etc
Brought to you by:
zzzeek
From: <co...@sq...> - 2006-05-28 00:31:56
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><style type="text/css"><!-- #msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; } #msg dt { float: left; width: 6em; font-weight: bold; } #msg dt:after { content:':';} #msg dl, #msg dt, #msg ul, #msg li { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; } #msg dl a { font-weight: bold} #msg dl a:link { color:#fc3; } #msg dl a:active { color:#ff0; } #msg dl a:visited { color:#cc6; } h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; } #msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; } #msg ul, pre { overflow: auto; } #patch { width: 100%; } #patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;} #patch .propset h4, #patch .binary h4 {margin:0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;} #patch .propset .diff, #patch .binary .diff {padding:10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;} #patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;} #patch .lines, .info {color:#888;background:#fff;} --></style> <title>[1529] sqlalchemy/trunk/doc/build/content/sqlconstruction.txt: formatting etc</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>1529</dd> <dt>Author</dt> <dd>zzzeek</dd> <dt>Date</dt> <dd>2006-05-27 19:31:34 -0500 (Sat, 27 May 2006)</dd> </dl> <h3>Log Message</h3> <pre>formatting etc</pre> <h3>Modified Paths</h3> <ul> <li><a href="#sqlalchemytrunkdocbuildcontentsqlconstructiontxt">sqlalchemy/trunk/doc/build/content/sqlconstruction.txt</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="sqlalchemytrunkdocbuildcontentsqlconstructiontxt"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/doc/build/content/sqlconstruction.txt (1528 => 1529)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/doc/build/content/sqlconstruction.txt 2006-05-27 20:34:25 UTC (rev 1528) +++ sqlalchemy/trunk/doc/build/content/sqlconstruction.txt 2006-05-28 00:31:34 UTC (rev 1529) </span><span class="lines">@@ -127,10 +127,12 @@ </span><span class="cx"> # or get the underlying DBAPI cursor object </span><span class="cx"> cursor = result.cursor </span><span class="cx"> </span><del>- # close the result. If the statement was implicitly executed (i.e. without an explicit Connection), this will - # return the underlying connection resources back to the connection pool. de-referencing the result - # will also have the same effect. - # if an explicit Connection was used, then close() does nothing. </del><ins>+ # close the result. If the statement was implicitly executed + # (i.e. without an explicit Connection), this will + # return the underlying connection resources back to + # the connection pool. de-referencing the result + # will also have the same effect. if an explicit Connection was + # used, then close() does nothing. </ins><span class="cx"> result.close() </span><span class="cx"> </span><span class="cx"> #### Using Column Labels {@name=labels} </span><span class="lines">@@ -178,7 +180,8 @@ </span><span class="cx"> You can also specify custom labels on a per-column basis using the `label()` function: </span><span class="cx"> </span><span class="cx"> {python title="label() Function on Column"} </span><del>- {sql}c = select([users.c.user_id.label('id'), users.c.user_name.label('name')]).execute() </del><ins>+ {sql}c = select([users.c.user_id.label('id'), + users.c.user_name.label('name')]).execute() </ins><span class="cx"> SELECT users.user_id AS id, users.user_name AS name </span><span class="cx"> FROM users </span><span class="cx"> {} </span><span class="lines">@@ -319,7 +322,8 @@ </span><span class="cx"> users.select(users.c.user_id.in_(1,2,3)) </span><span class="cx"> </span><span class="cx"> # and_, endswith, equality operators </span><del>- users.select(and_(addresses.c.street.endswith('green street'), addresses.c.zip=='11234')) </del><ins>+ users.select(and_(addresses.c.street.endswith('green street'), + addresses.c.zip=='11234')) </ins><span class="cx"> </span><span class="cx"> # & operator subsituting for 'and_' </span><span class="cx"> users.select(addresses.c.street.endswith('green street') & (addresses.c.zip=='11234')) </span><span class="lines">@@ -471,7 +475,8 @@ </span><span class="cx"> A join can be created on its own using the `join` or `outerjoin` functions, or can be created off of an existing Table or other selectable unit via the `join` or `outerjoin` methods: </span><span class="cx"> </span><span class="cx"> {python} </span><del>- {sql}outerjoin(users, addresses, users.c.user_id==addresses.c.address_id).select().execute() </del><ins>+ {sql}outerjoin(users, addresses, + users.c.user_id==addresses.c.address_id).select().execute() </ins><span class="cx"> SELECT users.user_id, users.user_name, users.password, addresses.address_id, </span><span class="cx"> addresses.user_id, addresses.street, addresses.city, addresses.state, addresses.zip </span><span class="cx"> FROM users LEFT OUTER JOIN addresses ON users.user_id = addresses.address_id </span><span class="lines">@@ -581,7 +586,8 @@ </span><span class="cx"> Subqueries can be used in the column clause of a select statement by specifying the `scalar=True` flag: </span><span class="cx"> </span><span class="cx"> {python} </span><del>- {sql}select([table2.c.col1, table2.c.col2, select([table1.c.col1], table1.c.col2==7, scalar=True)]) </del><ins>+ {sql}select([table2.c.col1, table2.c.col2, + select([table1.c.col1], table1.c.col2==7, scalar=True)]) </ins><span class="cx"> SELECT table2.col1, table2.col2, </span><span class="cx"> (SELECT table1.col1 AS col1 FROM table1 WHERE col2=:table1_col2) </span><span class="cx"> FROM table2 </span><span class="lines">@@ -909,13 +915,13 @@ </span><span class="cx"> </span><span class="cx"> {python}s = select([addresses.c.city], addresses.c.user_id==users.c.user_id) </span><span class="cx"> {sql}users.update( </span><del>- and_(users.c.user_id>10, users.c.user_id&lt;20), </del><ins>+ and_(users.c.user_id>10, users.c.user_id<20), </ins><span class="cx"> values={users.c.user_name:s} </span><span class="cx"> ).execute() </span><span class="cx"> UPDATE users SET user_name=(SELECT addresses.city </span><span class="cx"> FROM addresses </span><span class="cx"> WHERE addresses.user_id = users.user_id) </span><del>- WHERE users.user_id > :users_user_id AND users.user_id &lt; :users_user_id_1 </del><ins>+ WHERE users.user_id > :users_user_id AND users.user_id < :users_user_id_1 </ins><span class="cx"> {'users_user_id_1': 20, 'users_user_id': 10} </span><span class="cx"> </span><span class="cx"> ### Deletes {@name=delete} </span></span></pre> </div> </div> </body> </html> |