]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
documentation updates
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 28 Mar 2010 15:20:22 +0000 (11:20 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 28 Mar 2010 15:20:22 +0000 (11:20 -0400)
15 files changed:
doc/build/reference/dialects/index.rst
doc/build/reference/dialects/mssql.rst
doc/build/reference/dialects/mysql.rst
doc/build/static/docs.css
lib/sqlalchemy/connectors/mxodbc.py
lib/sqlalchemy/dialects/mssql/mxodbc.py
lib/sqlalchemy/dialects/mssql/pymssql.py
lib/sqlalchemy/dialects/mssql/pyodbc.py
lib/sqlalchemy/dialects/mysql/__init__.py
lib/sqlalchemy/dialects/mysql/base.py
lib/sqlalchemy/dialects/mysql/mysqlconnector.py
lib/sqlalchemy/dialects/mysql/mysqldb.py
lib/sqlalchemy/dialects/mysql/oursql.py
lib/sqlalchemy/dialects/mysql/pyodbc.py
lib/sqlalchemy/dialects/mysql/zxjdbc.py

index 30781199e52536bb3fd3297490d9b08bae04e1f6..a1808dff9b90a36cb86f02aa6ca6d3ef3e2dec39 100644 (file)
@@ -18,6 +18,7 @@ current versions of SQLAlchemy.
     oracle
     postgresql
     sqlite
+    sybase
 
 Unsupported Databases
 ---------------------
@@ -31,5 +32,4 @@ ported to current versions of SQLAlchemy.
     access
     informix
     maxdb
-    sybase
 
index 4bbb3181b08998d6feec492067640dc15dba1cc9..ebb3598678891fe47055fffd1f57c3d5bca90449 100644 (file)
@@ -7,6 +7,10 @@ PyODBC
 ------
 .. automodule:: sqlalchemy.dialects.mssql.pyodbc
 
+mxODBC
+------
+.. automodule:: sqlalchemy.dialects.mssql.mxodbc
+
 pymssql
 -------
 .. automodule:: sqlalchemy.dialects.mssql.pymssql
index f05d751c556c29fe4eaabafd9da31bc26943db20..0a2af11b5a3e75394cd79a6d79c4aa4ad9d21e2e 100644 (file)
@@ -6,6 +6,8 @@ MySQL
 MySQL Column Types
 ------------------
 
+.. automodule:: sqlalchemy.dialects.mysql
+    
 .. autoclass:: NUMERIC
    :members: __init__
    :show-inheritance:
index ad6f999e652729cd7c319a6aa245c9bf7204bdf7..33fbca52771855209bdd8e89d2b03cae486ccbbc 100644 (file)
@@ -2,12 +2,13 @@
 
 body, td {
        font-family: verdana, sans-serif;
-       font-size:.95em;
+       font-size:.9em;
 }
 
 body {
        background-color: #FDFBFC;
-       margin:20px 20px 20px 20px;
+       margin:38px;
+       color:#333333;
 }
 
 form {
@@ -20,7 +21,10 @@ p {
 }
 
 
-a {font-weight:normal; text-decoration:underline;}
+a {
+        font-weight:normal; 
+        text-decoration:none;
+}
 a:link {color:#0000FF;}
 a:visited {color:#0000FF;}
 a:active {color:#0000FF;}
@@ -57,7 +61,7 @@ strong a {
 
 .topnav .prevnext {
     padding: 5px 0px 0px 0px;
-    font-size: 0.8em
+    /*font-size: 0.8em*/
 }
 
 h1, h2, h3, h4, h5 {
index f50bff7dac8b4088e2908090ac089423bedcc766..816474d4321bcc802bf2e1726ad9702441be68ec 100644 (file)
@@ -9,6 +9,7 @@ and 2008, using the SQL Server Native driver. However, it is
 possible for this to be used on other database platforms.
 
 For more info on mxODBC, see http://www.egenix.com/
+
 """
 
 import sys
index 7148a36287d64e8e33931023a26fd4b20908a4ce..efe76365964489a510121b0b471b586b1942cd5f 100644 (file)
@@ -1,9 +1,41 @@
 """
-MSSQL dialect tweaked to work with mxODBC, mainly by making use
-of the MSSQLStrictCompiler.
+Support for MS-SQL via mxODBC.
+
+mxODBC is available at:
+
+    http://www.egenix.com/
 
 This was tested with mxODBC 3.1.2 and the SQL Server Native
 Client connected to MSSQL 2005 and 2008 Express Editions.
+
+Connecting
+~~~~~~~~~~
+
+Connection is via DSN::
+
+    mssql+mxodbc://<username>:<password>@<dsnname>
+    
+Execution Modes
+~~~~~~~~~~~~~~~
+
+mxODBC features two styles of statement execution, using the ``cursor.execute()``
+and ``cursor.executedirect()`` methods (the second being an extension to the 
+DBAPI specification).   The former makes use of the native
+parameter binding services of the ODBC driver, while the latter uses string escaping.
+The primary advantage to native parameter binding is that the same statement, when
+executed many times, is only prepared once.   Whereas the primary advantage to the
+latter is that the rules for bind parameter placement are relaxed.   MS-SQL has very 
+strict rules for native binds, including that they cannot be placed within the argument
+lists of function calls, anywhere outside the FROM, or even within subqueries within the
+FROM clause - making the usage of bind parameters within SELECT statements impossible for 
+all but the most simplistic statements.  For this reason, the mxODBC dialect uses the 
+"native" mode by default only for INSERT, UPDATE, and DELETE statements, and uses the
+escaped string mode for all other statements.   This behavior can be controlled completely
+via :meth:`~sqlalchemy.sql.expression.Executable.execution_options`
+using the ``native_odbc_execute`` flag with a value of ``True`` or ``False``, where a value of 
+``True`` will unconditionally use native bind parameters and a value of ``False`` will 
+uncondtionally use string-escaped parameters.
+
 """
 
 import re
index 36cb5f370240f896e588ce21cbe707ac644fcbe5..ca1c4a1420265c9694c5cdd73c7d9d2a9d658a2c 100644 (file)
@@ -7,7 +7,10 @@ pymssql is available at:
 
     http://pymssql.sourceforge.net/
     
-Connect string::
+Connecting
+^^^^^^^^^^
+    
+Sample connect string::
 
     mssql+pymssql://<username>:<password>@<freetds_name>
 
@@ -16,6 +19,9 @@ strings as Python unicode objects.   This can potentially improve
 performance in some scenarios as decoding of strings is 
 handled natively.
 
+Limitations
+^^^^^^^^^^^
+
 pymssql inherits a lot of limitations from FreeTDS, including:
 
 * no support for multibyte schema identifiers
index eb4bf5cfff892dd984afa3239db143f029558118..c74be0e53c621b60d185dcc9b64e1d0f0108f5c5 100644 (file)
@@ -5,6 +5,9 @@ pyodbc is available at:
 
     http://pypi.python.org/pypi/pyodbc/
 
+Connecting
+^^^^^^^^^^
+
 Examples of pyodbc connection string URLs:
 
 * ``mssql+pyodbc://mydsn`` - connects using the specified DSN named ``mydsn``.
index e4ecccdfc744b4666b53c6744f7e36f433037c49..f37a0c76673a8345e7fd89e9e53aac2b6441d54d 100644 (file)
@@ -6,12 +6,12 @@ base.dialect = mysqldb.dialect
 from sqlalchemy.dialects.mysql.base import \
     BIGINT, BINARY, BIT, BLOB, BOOLEAN, CHAR, DATE, DATETIME, DECIMAL, DOUBLE, ENUM, DECIMAL,\
     FLOAT, INTEGER, INTEGER, LONGBLOB, LONGTEXT, MEDIUMBLOB, MEDIUMINT, MEDIUMTEXT, NCHAR, \
-    NVARCHAR, NUMERIC, SET, SMALLINT, TEXT, TIME, TIMESTAMP, TINYBLOB, TINYINT, TINYTEXT,\
+    NVARCHAR, NUMERIC, SET, SMALLINT, REAL, TEXT, TIME, TIMESTAMP, TINYBLOB, TINYINT, TINYTEXT,\
     VARBINARY, VARCHAR, YEAR, dialect
     
 __all__ = (
 'BIGINT', 'BINARY', 'BIT', 'BLOB', 'BOOLEAN', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'DOUBLE',
 'ENUM', 'DECIMAL', 'FLOAT', 'INTEGER', 'INTEGER', 'LONGBLOB', 'LONGTEXT', 'MEDIUMBLOB', 'MEDIUMINT',
-'MEDIUMTEXT', 'NCHAR', 'NVARCHAR', 'NUMERIC', 'SET', 'SMALLINT', 'TEXT', 'TIME', 'TIMESTAMP',
+'MEDIUMTEXT', 'NCHAR', 'NVARCHAR', 'NUMERIC', 'SET', 'SMALLINT', 'REAL', 'TEXT', 'TIME', 'TIMESTAMP',
 'TINYBLOB', 'TINYINT', 'TINYTEXT', 'VARBINARY', 'VARCHAR', 'YEAR', 'dialect'
 )
index 6650b8388ef5a8912a3eb2976b3b134a0e4ea3e2..6a07614763ad8bca7133d52b1baaddb9b4c90df0 100644 (file)
@@ -1,37 +1,13 @@
 # -*- fill-column: 78 -*-
-# mysql.py
+# mysql/base.py
 # Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Michael Bayer mike_mp@zzzcomputing.com
+# and Jason Kirtland.
 #
 # This module is part of SQLAlchemy and is released under
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
 """Support for the MySQL database.
 
-Overview
---------
-
-For normal SQLAlchemy usage, importing this module is unnecessary.  It will be
-loaded on-demand when a MySQL connection is needed.  The generic column types
-like :class:`~sqlalchemy.String` and :class:`~sqlalchemy.Integer` will
-automatically be adapted to the optimal matching MySQL column type.
-
-But if you would like to use one of the MySQL-specific or enhanced column
-types when creating tables with your :class:`~sqlalchemy.Table` definitions,
-then you will need to import them from this module::
-
-  from sqlalchemy.dialect.mysql import base as mysql
-
-  Table('mytable', metadata,
-        Column('id', Integer, primary_key=True),
-        Column('ittybittyblob', mysql.TINYBLOB),
-        Column('biggy', mysql.BIGINT(unsigned=True)))
-
-All standard MySQL column types are supported.  The OpenGIS types are
-available for use via table reflection but have no special support or mapping
-to Python classes.  If you're using these types and have opinions about how
-OpenGIS can be smartly integrated into SQLAlchemy please join the mailing
-list!
-
 Supported Versions and Features
 -------------------------------
 
@@ -44,10 +20,7 @@ in the suite 100%.  No heroic measures are taken to work around major missing
 SQL features- if your server version does not support sub-selects, for
 example, they won't work in SQLAlchemy either.
 
-Currently, the only DB-API driver supported is `MySQL-Python` (also referred to
-as `MySQLdb`).  Either 1.2.1 or 1.2.2 are recommended.  The alpha, beta and
-gamma releases of 1.2.1 and 1.2.2 should be avoided.  Support for Jython and
-IronPython is planned.
+Most available DBAPI drivers are supported; see below.
 
 =====================================  ===============
 Feature                                Minimum Version
@@ -64,6 +37,37 @@ Nested Transactions                    5.0.3
 See the official MySQL documentation for detailed information about features
 supported in any given server release.
 
+Connecting
+----------
+
+See the API documentation on individual drivers for details on connecting.
+    
+Data Types
+----------
+
+All of MySQL's standard types are supported.   These can also be specified within 
+table metadata, for the purpose of issuing CREATE TABLE statements
+which include MySQL-specific extensions.   The types are available
+from the module, as in::
+
+    from sqlalchemy.dialects import mysql
+
+    Table('mytable', metadata,
+          Column('id', Integer, primary_key=True),
+          Column('ittybittyblob', mysql.TINYBLOB),
+          Column('biggy', mysql.BIGINT(unsigned=True)))
+
+See the API documentation on specific column types for further details.
+
+Connection Timeouts
+-------------------
+
+MySQL features an automatic connection close behavior, for connections that have
+been idle for eight hours or more.   To circumvent having this issue, use the 
+``pool_recycle`` option which controls the maximum age of any connection::
+
+    engine = create_engine('mysql+mysqldb://...', pool_recycle=3600)
+
 Storage Engines
 ---------------
 
@@ -159,20 +163,13 @@ And of course any valid MySQL statement can be executed as a string as well.
 Some limited direct support for MySQL extensions to SQL is currently
 available.
 
-  * SELECT pragma::
-
-      select(..., prefixes=['HIGH_PRIORITY', 'SQL_SMALL_RESULT'])
-
-  * UPDATE with LIMIT::
+* SELECT pragma::
 
-      update(..., mysql_limit=10)
+    select(..., prefixes=['HIGH_PRIORITY', 'SQL_SMALL_RESULT'])
 
-Boolean Types
--------------
+* UPDATE with LIMIT::
 
-MySQL's BOOL type is a synonym for SMALLINT, so is actually a numeric value,
-and additionally MySQL doesn't support CHECK constraints. Therefore SQLA's
-Boolean type cannot fully constrain values to just "True" and "False" the way it does for most other backends.
+    update(..., mysql_limit=10)
 
 Troubleshooting
 ---------------
index 981e1e204b535cd410d75f5b3bcc0e5c42b76579..2da18e50ff7cbba441156acd3f837f806da1ed72 100644 (file)
@@ -1,6 +1,15 @@
 """Support for the MySQL database via the MySQL Connector/Python adapter.
 
-# TODO: add docs/notes here regarding MySQL Connector/Python
+MySQL Connector/Python is available at:
+
+    https://launchpad.net/myconnpy
+
+Connecting
+-----------
+
+Connect string format::
+
+    mysql+mysqlconnector://<user>:<password>@<host>[:<port>]/<dbname>
 
 """
 
index 9d34939a1ff86193990436fc6f5b9ba13f5fd2fe..6e6bb0ecc6706323e71d51911621973f4debe40e 100644 (file)
@@ -1,5 +1,18 @@
 """Support for the MySQL database via the MySQL-python adapter.
 
+MySQL-Python is available at:
+
+    http://sourceforge.net/projects/mysql-python
+    
+At least version 1.2.1 or 1.2.2 should be used.
+
+Connecting
+-----------
+
+Connect string format::
+
+    mysql+mysqldb://<user>:<password>@<host>[:<port>]/<dbname>
+    
 Character Sets
 --------------
 
@@ -14,10 +27,21 @@ enabling ``use_unicode`` in the driver by default.  For regular encoded
 strings, also pass ``use_unicode=0`` in the connection arguments::
 
   # set client encoding to utf8; all strings come back as unicode
-  create_engine('mysql:///mydb?charset=utf8')
+  create_engine('mysql+mysqldb:///mydb?charset=utf8')
 
   # set client encoding to utf8; all strings come back as utf8 str
-  create_engine('mysql:///mydb?charset=utf8&use_unicode=0')
+  create_engine('mysql+mysqldb:///mydb?charset=utf8&use_unicode=0')
+
+Known Issues
+-------------
+
+MySQL-python at least as of version 1.2.2 has a serious memory leak related
+to unicode conversion, a feature which is disabled via ``use_unicode=0``.   
+The recommended connection form with SQLAlchemy is::
+
+    engine = create_engine('mysql://scott:tiger@localhost/test?charset=utf8&use_unicode=0', pool_recycle=3600)
+
+
 """
 
 import re
index 9e38993f24a2187e40b8378d282496b5ffbeb947..ebc7264823d2dfc03d6682f0560c09e1ac92e437 100644 (file)
@@ -1,5 +1,16 @@
 """Support for the MySQL database via the oursql adapter.
 
+OurSQL is available at:
+
+    http://packages.python.org/oursql/
+    
+Connecting
+-----------
+
+Connect string format::
+
+    mysql+oursql://<user>:<password>@<host>[:<port>]/<dbname>
+
 Character Sets
 --------------
 
index 5add45b2168a32beee3423031a01c333c7bdeb8a..1f73c6ef12de4e1eef056453d07b31add60a2bcd 100644 (file)
@@ -1,5 +1,24 @@
 """Support for the MySQL database via the pyodbc adapter.
 
+pyodbc is available at:
+
+    http://pypi.python.org/pypi/pyodbc/
+
+Connecting
+----------
+
+Connect string::
+
+    mysql+pyodbc://<username>:<password>@<dsnname>
+
+Limitations
+-----------
+
+The mysql-pyodbc dialect is subject to unresolved character encoding issues 
+which exist within the current ODBC drivers available.
+(see http://code.google.com/p/pyodbc/issues/detail?id=25).   Consider usage
+of OurSQL, MySQLdb, or MySQL-connector/Python.
+
 """
 
 from sqlalchemy.dialects.mysql.base import MySQLDialect, MySQLExecutionContext
index f4cf0013c494c0ca24bf5b73fc3b999893b60894..06d3e66160352fb102374ba629b4959fc4e71f1a 100644 (file)
@@ -6,6 +6,13 @@ JDBC Driver
 The official MySQL JDBC driver is at
 http://dev.mysql.com/downloads/connector/j/.
 
+Connecting
+----------
+
+Connect string format:
+
+    mysql+zxjdbc://<user>:<password>@<hostname>[:<port>]/<database>
+
 Character Sets
 --------------