From: Mike Bayer Date: Thu, 7 Jul 2005 04:05:24 +0000 (+0000) Subject: docs X-Git-Tag: rel_0_1_0~906 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4e5dc35501e2c87b4156530c2dc20be6bed4ad8c;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git docs --- diff --git a/doc/build/components/printsection.myt b/doc/build/components/printsection.myt new file mode 100644 index 0000000000..006b890555 --- /dev/null +++ b/doc/build/components/printsection.myt @@ -0,0 +1,155 @@ +<%args> + toc + paged + comp + isdynamic + index + ext + onepage + + +<%python scope="init"> + # get the item being requested by this embedded component from the documentation tree + try: + current = toc.get_file(comp.get_name()) + except KeyError: + current = None + + +% if paged == 'yes': +% if current is None: + <& toc, includefile = True, **ARGS &> +% else: + + <& topnav, item=current, **ARGS &> +
+ <& formatting.myt:printitem, item=current, includefile = True, omitheader = True &> +
+% # if/else +% else: + <& toc, includefile = False, **ARGS &> +
+% for i in toc.children: +
+ + +
+ <& topnav, item=i, **ARGS &> +
+ + <& formatting.myt:printitem, item=i, includefile = False, omitheader = True &> +
+% # for i +
+ +% # if/else + + +<%method topnav> + <%args> + isdynamic + paged + item + index + ext + onepage + +% ispaged = (paged =='yes') + +
+ +<& topnavcontrol, **ARGS &> + + + + +
+
<% item.description %>
+
+ <& formatting.myt:printtoc, root = item, includefile = False, current = None, full = True &> +
+
+ +
+ + +<%method topnavcontrol> + <%args> + isdynamic + paged + index + ext + onepage + +% ispaged = (paged =='yes') + +
+% if ispaged: + View: Paged  |  One Page +% else: + View: Paged  |  One Page +% +
+ + + +<%method toc> + <%args> + toc + includefile = True + isdynamic + paged + index + ext + onepage + + + +
+ <& topnavcontrol, **ARGS &> + + + Table of Contents +    + (view full table) +

+ +
+ <& formatting.myt:printtoc, root = toc, includefile = includefile, current = None, full = False, children=False &> +
+ +
+ + +
+ + Table of Contents: Full +    + (view brief table) +

+ +
+ <& formatting.myt:printtoc, root = toc, includefile = includefile, current = None, full = True, children=True &> +
+ +
+ diff --git a/doc/build/content/coolthings.myt b/doc/build/content/coolthings.myt new file mode 100644 index 0000000000..2520cd6fb8 --- /dev/null +++ b/doc/build/content/coolthings.myt @@ -0,0 +1,101 @@ +<%flags>inherit='document_base.myt' + + + +<&|doclib.myt:item, name="coolthings", description="Cool Things You Can Do With SQLAlchemy" &> + +<&|formatting.myt:code, syntaxtype="python" &> +# first, some imports +from sqlalchemy.sql import * +from sqlalchemy.schema import * + + +# make a database engine based on sqlite +import sqlalchemy.databases.sqlite as sqlite_db +db = sqlite_db.engine('foo.db', pool_size = 10, max_overflow = 5) + +# define metadata for a table + +users = Table('users', db, + Column('user_id', INT), + Column('user_name', VARCHAR(20)), + Column('password', CHAR(10)) +) + + +# select rows from the table + +query = users.select() +cursor = query.execute() +rows = cursor.fetchall() + + +# select rows from the table where user_name=='ed' +rows = users.select(users.c.user_name == 'ed').execute().fetchall() + +# make a query with a bind param +query = select([users], users.c.user_id == bindparam('userid')) + +# execute with params +rows = query.execute(userid = 7).fetchall() + + +# make another table +addresses = Table('addresses', db, + Column('address_id', INT), + Column('user_id', INT), + Column('street', VARCHAR(20)), + Column('city', VARCHAR(20)), + Column('state', CHAR(2)), + Column('zip', CHAR(5)) +) + +# no, really, make this table in the DB via CREATE +addresses.build() + + +# make a nonsensical query that selects from an outer join, and +# throws in a literally-defined EXISTS clause +query = select( + [users, addresses], + and_( + addresses.c.street == 'Green Street', + addresses.c.city == 'New York', + users.c.user_id != 12, + "EXISTS (select 1 from special_table where user_id=users.user_id)" + ), + from_obj = [ outerjoin(users, addresses, addresses.user_id==users.user_id) ] + ) + + +# insert into a table +users.insert().execute(user_id = 7, user_name = 'jack') + +# update the table +users.update(users.c.user_id == 7).execute(user_name = 'fred') + + +# get DBAPI connections from the higher-level engine +c = db.connection() + + +# use the connection pooling directly: + +# import a real DBAPI database +from pysqlite2 import dbapi2 as sqlite + +# make an implicit pool around it +import sqlalchemy.pool as pool +sqlite = pool.manage(sqlite, pool_size = 10, max_overflow = 5, use_threadlocal = True) + +# get a pooled connection local to the current thread +c = sqlite.connect('foo.db') +cursor = c.cursor() + +# return the connection to the pool +cursor = None +c = None + + + + diff --git a/doc/build/content/document_base.myt b/doc/build/content/document_base.myt new file mode 100644 index 0000000000..35c41d545f --- /dev/null +++ b/doc/build/content/document_base.myt @@ -0,0 +1,24 @@ +<%flags>inherit="doclib.myt" + +<%python scope="global"> + + files = [ + 'coolthings' + ] + + + +<%attr> + files=files + wrapper='section_wrapper.myt' + onepage='documentation' + index='index' + title='SQLAlchemy Documentation' + version = '0.91' + + + + + + + diff --git a/doc/docs.css b/doc/docs.css new file mode 100644 index 0000000000..e7384ed658 --- /dev/null +++ b/doc/docs.css @@ -0,0 +1,170 @@ +/* documentation section styles */ + +.doccontainer { +} + +.panecontainer { +} + +.sidebar { + background-color: #EEEEFB; + border: 1px solid; + padding: 5px 5px 5px 5px; + margin: 0px 5px 5px 0px; + width:120px; + float:left; +} + + +.sectionnavblock { +} + +.sectionnav { + background-color: #EEEEFB; + border: 1px solid; + padding: 10px 10px 10px 10px; + margin: 35px 0px 15px 5px; + float:right; +} + + +.topnav { + background-color: #EEEEFB; + border: 1px solid; + padding:10px 10px 0px 10px; + margin:0px 0px 10px 0px; +} + +.tipbox { + background-color: #EEEEFB; + border:1px solid; + padding:10px; + margin: 5px; +} + +/* optional margin to add to topnav */ +.topnavmargin { + margin:10px; +} + +.topnavsectionlink { + padding: 0px 0px 0px 0px; + margin: 0px 0px 0px 0px; +} + +.topnavcontrol { + float:right; +} + +.topnavmain { + margin: 25px 5px 15px 5px; +} + +.topnavheader { + font-weight: bold; + font-size: 16px; + margin: 0px 0px 0px 0px; + padding:0px 0px 15px 0px; +} + +.topnavitems { + margin: 0px 0px 0px 40px; +} + +.prevnext { + padding: 5px 0px 0px 0px; +} + +.code { + font-family:courier, serif; + font-size:12px; + background-color: #E2E2EB; + padding:2px 2px 2px 10px; + margin: 5px 5px 5px 5px; +} + +.codetitle { + font-family: verdana, sans-serif; + font-size: 12px; + font-weight: bold; + text-decoration:underline; + padding:5px; +} + +.codeline { + font-family:courier, serif; + font-size:12px; +} + + +.content { + border: 1px solid; + padding: 0px 10px 20px 0px; +} + +.sectioncontent { + border: 1px solid; + padding: 0px 10px 20px 0px; +} + +.onepagecontent { + border: 1px solid; + margin: 0px 0px 0px 0px; +} + +.docheadertext { + font-size: 16px; + font-weight: bold; +} + +.docheader { + margin: 0px 0px 10px 0px; +} + +.subsection { + /* this style is dynamically modified by the indentation */ + margin:15px 0px 0px 0px; + clear:right; +} + +.section { + padding: 20px 0px 0px 0px; +} + +.sectionheadertext { + font-weight: bold; + font-size: 16px; +} + +.sectiontext { + font-size: 12px; + margin: 5px 0px 0px 0px; +} + +.maintoc { + background-color: #EEEEFB; + border: 1px solid; + padding: 10px 10px 10px 10px; + margin: 0px 0px 10px 0px; +} + +.toclinkcontainer { + padding:0px 0px 0px 8px; + /*border:1px solid;*/ +} + +.tocsection { + padding:2px 2px 2px 8px; +} + +.toclink { + font-size: 12px; + padding:0px 0px 3px 8px; + /*border:1px solid;*/ +} + +.smalltoclink { + font-size: 11px; + padding:0px 0px 3px 0px; +} +