summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/engine/default.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-08-18 21:37:48 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-08-18 21:37:48 +0000
commit7c6c1b99c2de00829b6f34ffba7e3bb689d34198 (patch)
treeacd6f8dc84cea86fc58b195a5f1068cbe020e955 /lib/sqlalchemy/engine/default.py
parent534cf5fdbd05e2049ab9feceabf3926a5ab6380c (diff)
downloadsqlalchemy-7c6c1b99c2de00829b6f34ffba7e3bb689d34198.tar.gz
1. Module layout. sql.py and related move into a package called "sql".
2. compiler names changed to be less verbose, unused classes removed. 3. Methods on Dialect which return compilers, schema generators, identifier preparers have changed to direct class references, typically on the Dialect class itself or optionally as attributes on an individual Dialect instance if conditional behavior is needed. This takes away the need for Dialect subclasses to know how to instantiate these objects, and also reduces method overhead by one call for each one. 4. as a result of 3., some internal signatures have changed for things like compiler() (now statement_compiler()), preparer(), etc., mostly in that the dialect needs to be passed explicitly as the first argument (since they are just class references now). The compiler() method on Engine and Connection is now also named statement_compiler(), but as before does not take the dialect as an argument. 5. changed _process_row function on RowProxy to be a class reference, cuts out 50K method calls from insertspeed.py
Diffstat (limited to 'lib/sqlalchemy/engine/default.py')
-rw-r--r--lib/sqlalchemy/engine/default.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/sqlalchemy/engine/default.py b/lib/sqlalchemy/engine/default.py
index ccaf080e7..059395921 100644
--- a/lib/sqlalchemy/engine/default.py
+++ b/lib/sqlalchemy/engine/default.py
@@ -9,7 +9,7 @@
from sqlalchemy import schema, exceptions, sql, util
import re, random
from sqlalchemy.engine import base
-
+from sqlalchemy.sql import compiler, expression
AUTOCOMMIT_REGEXP = re.compile(r'\s*(?:UPDATE|INSERT|CREATE|DELETE|DROP|ALTER)',
re.I | re.UNICODE)
@@ -18,6 +18,12 @@ SELECT_REGEXP = re.compile(r'\s*SELECT', re.I | re.UNICODE)
class DefaultDialect(base.Dialect):
"""Default implementation of Dialect"""
+ schemagenerator = compiler.SchemaGenerator
+ schemadropper = compiler.SchemaDropper
+ statement_compiler = compiler.DefaultCompiler
+ preparer = compiler.IdentifierPreparer
+ defaultrunner = base.DefaultRunner
+
def __init__(self, convert_unicode=False, encoding='utf-8', default_paramstyle='named', paramstyle=None, dbapi=None, **kwargs):
self.convert_unicode = convert_unicode
self.encoding = encoding
@@ -25,6 +31,7 @@ class DefaultDialect(base.Dialect):
self._ischema = None
self.dbapi = dbapi
self._figure_paramstyle(paramstyle=paramstyle, default=default_paramstyle)
+ self.identifier_preparer = self.preparer(self)
def dbapi_type_map(self):
# most DBAPIs have problems with this (such as, psycocpg2 types
@@ -46,6 +53,7 @@ class DefaultDialect(base.Dialect):
typeobj = typeobj()
return typeobj
+
def supports_unicode_statements(self):
"""indicate whether the DBAPI can receive SQL statements as Python unicode strings"""
return False
@@ -96,13 +104,13 @@ class DefaultDialect(base.Dialect):
return "_sa_%032x" % random.randint(0,2**128)
def do_savepoint(self, connection, name):
- connection.execute(sql.SavepointClause(name))
+ connection.execute(expression.SavepointClause(name))
def do_rollback_to_savepoint(self, connection, name):
- connection.execute(sql.RollbackToSavepointClause(name))
+ connection.execute(expression.RollbackToSavepointClause(name))
def do_release_savepoint(self, connection, name):
- connection.execute(sql.ReleaseSavepointClause(name))
+ connection.execute(expression.ReleaseSavepointClause(name))
def do_executemany(self, cursor, statement, parameters, **kwargs):
cursor.executemany(statement, parameters)
@@ -110,8 +118,6 @@ class DefaultDialect(base.Dialect):
def do_execute(self, cursor, statement, parameters, **kwargs):
cursor.execute(statement, parameters)
- def defaultrunner(self, context):
- return base.DefaultRunner(context)
def is_disconnect(self, e):
return False