]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- added db modules to genned docstrings
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 18 Mar 2007 22:35:19 +0000 (22:35 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 18 Mar 2007 22:35:19 +0000 (22:35 +0000)
- 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 *

doc/build/gen_docstrings.py
lib/sqlalchemy/databases/__init__.py
lib/sqlalchemy/databases/mssql.py
lib/sqlalchemy/databases/mysql.py
lib/sqlalchemy/databases/oracle.py
lib/sqlalchemy/databases/postgres.py
lib/sqlalchemy/engine/__init__.py
lib/sqlalchemy/engine/url.py

index 0360ef96fa84bf4be982020124ad82826ead5e90..ced16af24fb2a87573672082c320313d1c476ae7 100644 (file)
@@ -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):
index 7d1c7ef11494f45227b852817c2d9c59f1162276..b6304737789844354d039b22dc4a93ceb55b62ba 100644 (file)
@@ -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']
index 9ae65725071f3e4badaa5068245ca19c3e555c28..f16fcdc97dcf0447ed5ae0505731d5ef3062bcee 100644 (file)
@@ -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)
index 2df16c361d642cbd0c26e8d429b3393bd28fd8ff..e2784a1361ed0b847448fd322819b0d401e5c2eb 100644 (file)
@@ -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]
index 1dba60c1d7419503eff9848c14842cbc38060dc3..efc9a27814fc46f8779c7d731089fbf01449c6c5 100644 (file)
@@ -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
index 83dac516a9857d0dcf838e9d301550f5ff6469d2..20686f9ea2a7ec37441499f4552210f68c44dd6d 100644 (file)
@@ -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()
index e72c3755376c60ff18f26ca363ad6dda8d96661c..43dec46e3cc89c33242e25fa266494a102f31b9d 100644 (file)
@@ -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
index 8f9d33d54b2ed4fcbd9c98595ce1247c250e1362..353a9f8406a75d515fcb9ff6bf3c810489775444 100644 (file)
@@ -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.