diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-03-18 22:35:19 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-03-18 22:35:19 +0000 |
| commit | 43b70fc86b1c7b0549a2902559be932ca361921b (patch) | |
| tree | 1435c517cecc676ffb8b490082b87933730276a1 | |
| parent | 8f788f683ba64e7e0c495454883ca18dd2ae5f11 (diff) | |
| download | sqlalchemy-43b70fc86b1c7b0549a2902559be932ca361921b.tar.gz | |
- added db modules to genned docstrings
- had to tweak out latest MS-SQL module change. cant do ImportErrors right now until module
importing is moved to the connection phase across all dialects.
- took out "his" from url docstrings
- postgres doesnt do an import *
| -rw-r--r-- | doc/build/gen_docstrings.py | 3 | ||||
| -rw-r--r-- | lib/sqlalchemy/databases/__init__.py | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/databases/mssql.py | 22 | ||||
| -rw-r--r-- | lib/sqlalchemy/databases/mysql.py | 9 | ||||
| -rw-r--r-- | lib/sqlalchemy/databases/oracle.py | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/databases/postgres.py | 9 | ||||
| -rw-r--r-- | lib/sqlalchemy/engine/__init__.py | 3 | ||||
| -rw-r--r-- | lib/sqlalchemy/engine/url.py | 4 |
8 files changed, 28 insertions, 26 deletions
diff --git a/doc/build/gen_docstrings.py b/doc/build/gen_docstrings.py index 0360ef96f..ced16af24 100644 --- a/doc/build/gen_docstrings.py +++ b/doc/build/gen_docstrings.py @@ -14,6 +14,7 @@ import sqlalchemy.ext.proxy as proxy import sqlalchemy.ext.sessioncontext as sessioncontext import sqlalchemy.mods.threadlocal as threadlocal import sqlalchemy.ext.selectresults as selectresults +import sqlalchemy.databases as databases def make_doc(obj, classes=None, functions=None): """generate a docstring.ObjectDoc structure for an individual module, list of classes, and list of functions.""" @@ -39,7 +40,7 @@ def make_all_docs(): make_doc(obj=selectresults), make_doc(obj=exceptions), make_doc(obj=proxy), - ] + ] + [make_doc(getattr(__import__('sqlalchemy.databases.%s' % m).databases, m)) for m in databases.__all__] return objects def create_docstring_toc(data, root): diff --git a/lib/sqlalchemy/databases/__init__.py b/lib/sqlalchemy/databases/__init__.py index 7d1c7ef11..b63047377 100644 --- a/lib/sqlalchemy/databases/__init__.py +++ b/lib/sqlalchemy/databases/__init__.py @@ -5,4 +5,4 @@ # the MIT License: http://www.opensource.org/licenses/mit-license.php -__all__ = ['oracle', 'postgres', 'sqlite', 'mysql', 'mssql', 'firebird'] +__all__ = ['sqlite', 'postgres', 'mysql', 'oracle', 'mssql', 'firebird'] diff --git a/lib/sqlalchemy/databases/mssql.py b/lib/sqlalchemy/databases/mssql.py index 9ae657250..f16fcdc97 100644 --- a/lib/sqlalchemy/databases/mssql.py +++ b/lib/sqlalchemy/databases/mssql.py @@ -20,8 +20,8 @@ Note that the start & increment values for sequences are optional and will default to 1,1. -* Support for ``SET IDENTITY_INSERT ON`` mode (automagic on / off for - ``INSERT``s) +* Support for ``SET IDENTITY_INSERT ON`` mode (automagic on / off for + ``INSERT`` s) * Support for auto-fetching of ``@@IDENTITY`` on ``INSERT`` @@ -33,12 +33,13 @@ Known issues / TODO: * No support for more than one ``IDENTITY`` column per table * No support for table reflection of ``IDENTITY`` columns with - (seed,increment) values other than (1,1) + (seed,increment) values other than (1,1) * No support for ``GUID`` type columns (yet) * pymssql has problems with binary and unicode data that this module does **not** work around + """ import sys, StringIO, string, types, re, datetime @@ -312,6 +313,7 @@ class MSSQLDialect(ansisql.ANSIDialect): } def __new__(cls, module_name=None, *args, **kwargs): + module = kwargs.get('module', None) if cls != MSSQLDialect: return super(MSSQLDialect, cls).__new__(cls, *args, **kwargs) if module_name: @@ -321,18 +323,24 @@ class MSSQLDialect(ansisql.ANSIDialect): if not hasattr(dialect, 'module'): raise dialect.saved_import_error return dialect(*args, **kwargs) + elif module: + return object.__new__(cls, *args, **kwargs) else: for dialect in dialect_preference: if hasattr(dialect, 'module'): return dialect(*args, **kwargs) - raise ImportError('No DBAPI module detected for MSSQL - please install adodbapi, pymssql or pyodbc') - - def __init__(self, module_name=None, auto_identity_insert=True, **params): + #raise ImportError('No DBAPI module detected for MSSQL - please install adodbapi, pymssql or pyodbc') + else: + return object.__new__(cls, *args, **kwargs) + + def __init__(self, module_name=None, module=None, auto_identity_insert=True, **params): + if not hasattr(self, 'module'): + self.module = module super(MSSQLDialect, self).__init__(**params) self.auto_identity_insert = auto_identity_insert self.text_as_varchar = False self.set_default_schema_name("dbo") - + def create_connect_args(self, url): opts = url.translate_connect_args(['host', 'database', 'user', 'password', 'port']) opts.update(url.query) diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py index 2df16c361..e2784a136 100644 --- a/lib/sqlalchemy/databases/mysql.py +++ b/lib/sqlalchemy/databases/mysql.py @@ -426,13 +426,8 @@ class MySQLDialect(ansisql.ANSIDialect): raise exceptions.NoSuchTableError(table.name) def moretableinfo(self, connection, table): - """Return (tabletype, {colname:foreignkey,...}) - execute(SHOW CREATE TABLE child) => - CREATE TABLE `child` ( - `id` int(11) default NULL, - `parent_id` int(11) default NULL, - KEY `par_ind` (`parent_id`), - CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`) ON DELETE CASCADE\n) TYPE=InnoDB + """runs SHOW CREATE TABLE to get foreign key/options information about the table. + """ c = connection.execute("SHOW CREATE TABLE " + table.fullname, {}) desc_fetched = c.fetchone()[1] diff --git a/lib/sqlalchemy/databases/oracle.py b/lib/sqlalchemy/databases/oracle.py index 1dba60c1d..efc9a2781 100644 --- a/lib/sqlalchemy/databases/oracle.py +++ b/lib/sqlalchemy/databases/oracle.py @@ -460,7 +460,7 @@ class OracleCompiler(ansisql.ANSICompiler): self.strings[column] = self.strings[column] + "(+)" def visit_insert(self, insert): - """``INSERT``s are required to have the primary keys be explicitly present. + """``INSERT`` s are required to have the primary keys be explicitly present. Mapper will by default not put them in the insert statement to comply with autoincrement fields that require they not be diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py index 83dac516a..20686f9ea 100644 --- a/lib/sqlalchemy/databases/postgres.py +++ b/lib/sqlalchemy/databases/postgres.py @@ -15,7 +15,6 @@ import sqlalchemy.ansisql as ansisql import sqlalchemy.types as sqltypes import sqlalchemy.exceptions as exceptions from sqlalchemy.databases import information_schema as ischema -from sqlalchemy import * import re try: @@ -383,7 +382,7 @@ class PGDialect(ansisql.ANSIDialect): ORDER BY a.attnum """ % schema_where_clause - s = text(SQL_COLS) + s = sql.text(SQL_COLS) c = connection.execute(s, table_name=table.name, schema=table.schema) rows = c.fetchall() @@ -439,7 +438,7 @@ class PGDialect(ansisql.ANSIDialect): sch = table.schema if '.' not in match.group(2) and sch is not None: default = match.group(1) + sch + '.' + match.group(2) + match.group(3) - colargs.append(PassiveDefault(sql.text(default))) + colargs.append(schema.PassiveDefault(sql.text(default))) table.append_column(schema.Column(name, coltype, nullable=nullable, *colargs)) @@ -452,7 +451,7 @@ class PGDialect(ansisql.ANSIDialect): AND i.indisprimary = 't') ORDER BY attnum """ - t = text(PK_SQL) + t = sql.text(PK_SQL) c = connection.execute(t, table=table_oid) for row in c.fetchall(): pk = row[0] @@ -466,7 +465,7 @@ class PGDialect(ansisql.ANSIDialect): ORDER BY 1 """ - t = text(FK_SQL) + t = sql.text(FK_SQL) c = connection.execute(t, table=table_oid) for conname, condef in c.fetchall(): m = re.search('FOREIGN KEY \((.*?)\) REFERENCES (?:(.*?)\.)?(.*?)\((.*?)\)', condef).groups() diff --git a/lib/sqlalchemy/engine/__init__.py b/lib/sqlalchemy/engine/__init__.py index e72c37553..43dec46e3 100644 --- a/lib/sqlalchemy/engine/__init__.py +++ b/lib/sqlalchemy/engine/__init__.py @@ -31,8 +31,7 @@ def engine_descriptors(): """ result = [] - #for module in sqlalchemy.databases.__all__: - for module in ['sqlite', 'postgres', 'mysql']: + for module in sqlalchemy.databases.__all__: module = getattr(__import__('sqlalchemy.databases.%s' % module).databases, module) result.append(module.descriptor()) return result diff --git a/lib/sqlalchemy/engine/url.py b/lib/sqlalchemy/engine/url.py index 8f9d33d54..353a9f840 100644 --- a/lib/sqlalchemy/engine/url.py +++ b/lib/sqlalchemy/engine/url.py @@ -17,13 +17,13 @@ class URL(object): Attributes on URL include: drivername - The name of the database backend. + The name of the database backend. this name will correspond to a module in sqlalchemy/databases username The user name for the connection. password - His password. + database password. host The name of the host. |
