summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/sqlsoup.py
diff options
context:
space:
mode:
authorJonathan Ellis <jbellis@gmail.com>2006-07-29 03:52:04 +0000
committerJonathan Ellis <jbellis@gmail.com>2006-07-29 03:52:04 +0000
commitb8895c5ffc20d35f5210686e3bf867b3c0fe6fe7 (patch)
tree81e236ccf21a9a867a9a28d0e50fe52b753f2c05 /lib/sqlalchemy/ext/sqlsoup.py
parent4c316c681726d3a5752162fe4aa33f858b774b4a (diff)
downloadsqlalchemy-b8895c5ffc20d35f5210686e3bf867b3c0fe6fe7.tar.gz
soup.engine property
Diffstat (limited to 'lib/sqlalchemy/ext/sqlsoup.py')
-rw-r--r--lib/sqlalchemy/ext/sqlsoup.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/sqlalchemy/ext/sqlsoup.py b/lib/sqlalchemy/ext/sqlsoup.py
index 51e5ba3c3..0ff0d39fd 100644
--- a/lib/sqlalchemy/ext/sqlsoup.py
+++ b/lib/sqlalchemy/ext/sqlsoup.py
@@ -97,6 +97,22 @@ tables or other joins.
>>> join2 = db.join(join1, db.books)
>>> join2.select()
[MappedJoin(name='Joe Student',email='student@example.edu',password='student',classname=None,admin=0,book_id=1,user_name='Joe Student',loan_date=datetime.datetime(2006, 7, 12, 0, 0),id=1,title='Mustards I Have Known',published_year='1989',authors='Jones')]
+
+
+Advanced Use
+============
+
+You can access the SqlSoup's engine attribute to compose SQL directly.
+The engine's <b>execute</b> method corresponds
+to the one of a DBAPI cursor, and returns a ResultProxy that has <b>fetch</b> methods
+you would also see on a cursor.
+
+ >>> rp = db.engine.execute('select name, email from users order by name')
+ >>> for name, email in rp.fetchall(): print name, email
+ Bhargan Basepair basepair+nospam@example.edu
+ Joe Student student@example.edu
+
+You can also pass this engine object to other SQLAlchemy constructs.
"""
from sqlalchemy import *
@@ -234,7 +250,6 @@ class SqlSoup:
args may either be an SQLEngine or a set of arguments suitable
for passing to create_engine
"""
- from sqlalchemy import MetaData
# meh, sometimes having method overloading instead of kwargs would be easier
if isinstance(args[0], MetaData):
args = list(args)
@@ -246,6 +261,9 @@ class SqlSoup:
self._metadata = metadata
self._cache = {}
self.schema = None
+ def engine(self):
+ return self._metadata._engine
+ engine = property(engine)
def delete(self, *args, **kwargs):
objectstore.delete(*args, **kwargs)
def flush(self):