[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r7619 - in trunk/gnue-common/src/datasources/drivers: . file post
From: |
reinhard |
Subject: |
[gnue] r7619 - in trunk/gnue-common/src/datasources/drivers: . file postgresql postgresql/Base postgresql/psycopg postgresql/pygresql postgresql/pypgsql sql sql/interbase sql/maxdb sql/msado sql/mysql sql/oracle sql/postgres sql/sqlite |
Date: |
Mon, 20 Jun 2005 04:40:33 -0500 (CDT) |
Author: reinhard
Date: 2005-06-20 04:40:30 -0500 (Mon, 20 Jun 2005)
New Revision: 7619
Added:
trunk/gnue-common/src/datasources/drivers/sql/
trunk/gnue-common/src/datasources/drivers/sql/__init__.py
trunk/gnue-common/src/datasources/drivers/sql/interbase/
trunk/gnue-common/src/datasources/drivers/sql/interbase/Behavior.py
trunk/gnue-common/src/datasources/drivers/sql/interbase/__init__.py
trunk/gnue-common/src/datasources/drivers/sql/interbase/kinterbasdb.py
trunk/gnue-common/src/datasources/drivers/sql/maxdb/
trunk/gnue-common/src/datasources/drivers/sql/maxdb/Behavior.py
trunk/gnue-common/src/datasources/drivers/sql/maxdb/__init__.py
trunk/gnue-common/src/datasources/drivers/sql/maxdb/maxdb.py
trunk/gnue-common/src/datasources/drivers/sql/msado/
trunk/gnue-common/src/datasources/drivers/sql/msado/Behavior.py
trunk/gnue-common/src/datasources/drivers/sql/msado/__init__.py
trunk/gnue-common/src/datasources/drivers/sql/msado/adodbapi.py
trunk/gnue-common/src/datasources/drivers/sql/mysql/
trunk/gnue-common/src/datasources/drivers/sql/mysql/Behavior.py
trunk/gnue-common/src/datasources/drivers/sql/mysql/__init__.py
trunk/gnue-common/src/datasources/drivers/sql/mysql/mysqldb.py
trunk/gnue-common/src/datasources/drivers/sql/oracle/
trunk/gnue-common/src/datasources/drivers/sql/oracle/Base.py
trunk/gnue-common/src/datasources/drivers/sql/oracle/Behavior.py
trunk/gnue-common/src/datasources/drivers/sql/oracle/__init__.py
trunk/gnue-common/src/datasources/drivers/sql/oracle/cxoracle.py
trunk/gnue-common/src/datasources/drivers/sql/oracle/dcoracle.py
trunk/gnue-common/src/datasources/drivers/sql/postgres/
trunk/gnue-common/src/datasources/drivers/sql/postgres/Base.py
trunk/gnue-common/src/datasources/drivers/sql/postgres/Behavior.py
trunk/gnue-common/src/datasources/drivers/sql/postgres/__init__.py
trunk/gnue-common/src/datasources/drivers/sql/postgres/psycopg.py
trunk/gnue-common/src/datasources/drivers/sql/postgres/pygresql.py
trunk/gnue-common/src/datasources/drivers/sql/postgres/pypgsql.py
trunk/gnue-common/src/datasources/drivers/sql/sqlite/
trunk/gnue-common/src/datasources/drivers/sql/sqlite/Behavior.py
trunk/gnue-common/src/datasources/drivers/sql/sqlite/__init__.py
trunk/gnue-common/src/datasources/drivers/sql/sqlite/pysqlite.py
Removed:
trunk/gnue-common/src/datasources/drivers/adodbapi/
trunk/gnue-common/src/datasources/drivers/interbase/
trunk/gnue-common/src/datasources/drivers/maxdb/
trunk/gnue-common/src/datasources/drivers/mysql/
trunk/gnue-common/src/datasources/drivers/oracle/
trunk/gnue-common/src/datasources/drivers/postgresql/Base/Connection.py
trunk/gnue-common/src/datasources/drivers/postgresql/Behavior.py
trunk/gnue-common/src/datasources/drivers/postgresql/__init__.py
trunk/gnue-common/src/datasources/drivers/postgresql/psycopg/Driver.py
trunk/gnue-common/src/datasources/drivers/postgresql/pygresql/Driver.py
trunk/gnue-common/src/datasources/drivers/postgresql/pypgsql/Driver.py
trunk/gnue-common/src/datasources/drivers/sqlite/
Modified:
trunk/gnue-common/src/datasources/drivers/file/Base.py
trunk/gnue-common/src/datasources/drivers/file/__init__.py
trunk/gnue-common/src/datasources/drivers/file/csvfile.py
trunk/gnue-common/src/datasources/drivers/file/dbffile.py
trunk/gnue-common/src/datasources/drivers/file/inifile.py
trunk/gnue-common/src/datasources/drivers/postgresql/psycopg/__init__.py
trunk/gnue-common/src/datasources/drivers/postgresql/pygresql/__init__.py
trunk/gnue-common/src/datasources/drivers/postgresql/pypgsql/__init__.py
Log:
Changed driver directory layout to only contain a single file per driver.
Modified: trunk/gnue-common/src/datasources/drivers/file/Base.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/file/Base.py 2005-06-18
11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/file/Base.py 2005-06-20
09:40:30 UTC (rev 7619)
@@ -21,6 +21,10 @@
#
# $Id$
+"""
+Generic database driver plugin for file based backends.
+"""
+
__noplugin__ = True
import glob
Modified: trunk/gnue-common/src/datasources/drivers/file/__init__.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/file/__init__.py 2005-06-18
11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/file/__init__.py 2005-06-20
09:40:30 UTC (rev 7619)
@@ -1,4 +1,4 @@
-# GNU Enterprise Datasource Library - Driver for GNUe-AppServer
+# GNU Enterprise Common Library - Database driver plugins for files
#
# Copyright 2000-2005 Free Software Foundation
#
@@ -22,7 +22,7 @@
# $Id$
"""
-Implementations of dbdrivers for use with various file formats
+Database driver plugins for file based backends.
"""
# =============================================================================
Modified: trunk/gnue-common/src/datasources/drivers/file/csvfile.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/file/csvfile.py 2005-06-18
11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/file/csvfile.py 2005-06-20
09:40:30 UTC (rev 7619)
@@ -21,6 +21,10 @@
#
# $Id$
+"""
+Database driver plugin for CSV file backends.
+"""
+
import csv
from gnue.common.datasources.drivers.file import Base
Modified: trunk/gnue-common/src/datasources/drivers/file/dbffile.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/file/dbffile.py 2005-06-18
11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/file/dbffile.py 2005-06-20
09:40:30 UTC (rev 7619)
@@ -21,6 +21,10 @@
#
# $Id$
+"""
+Database driver plugin for DBF file backends.
+"""
+
from gnue.common.datasources.drivers.file import Base
from gnue.common.datasources import GSchema
from gnue.common.utils import dbf
Modified: trunk/gnue-common/src/datasources/drivers/file/inifile.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/file/inifile.py 2005-06-18
11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/file/inifile.py 2005-06-20
09:40:30 UTC (rev 7619)
@@ -21,6 +21,10 @@
#
# $Id$
+"""
+Database driver plugin for INI style configuration file backends
+"""
+
import ConfigParser
from gnue.common.apps import errors
@@ -87,7 +91,7 @@
class Connection (Base.Connection):
"""
- Connection class for INI file backends.
+ Connection class for INI style configuration file backends.
"""
_primarykeyFields = ['_section_name']
Deleted: trunk/gnue-common/src/datasources/drivers/postgresql/Base/Connection.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/postgresql/Base/Connection.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/postgresql/Base/Connection.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -1,144 +0,0 @@
-# GNU Enterprise Common Library - Generic Postgres DB driver - Connection
-#
-# Copyright 2001-2005 Free Software Foundation
-#
-# This file is part of GNU Enterprise
-#
-# GNU Enterprise is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General Public
-# License as published by the Free Software Foundation; either
-# version 2, or (at your option) any later version.
-#
-# GNU Enterprise is distributed in the hope that it will be
-# useful, but WITHOUT ANY WARRANTY; without even the implied
-# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with program; see the file COPYING. If not,
-# write to the Free Software Foundation, Inc., 59 Temple Place
-# - Suite 330, Boston, MA 02111-1307, USA.
-#
-# $Id$
-
-__all__ = ['Connection']
-
-from gnue.common.datasources.drivers import DBSIG2
-from gnue.common.datasources.drivers.postgresql import Behavior
-
-
-# =============================================================================
-# Generic PostgreSQL Connection class
-# =============================================================================
-
-class Connection (DBSIG2.Connection):
- """
- Generic Connection class for PostgreSQL databases.
- """
-
- _rowidField = 'oid'
- _behavior = Behavior.Behavior
-
-
- # ---------------------------------------------------------------------------
- # Constructor
- # ---------------------------------------------------------------------------
-
- def __init__ (self, connections, name, parameters):
-
- DBSIG2.Connection.__init__ (self, connections, name, parameters)
-
- # Find out encoding for Postgres
- if pg_encTable.has_key (self._encoding):
- self._pg_encoding = pg_encTable [self._encoding]
- else:
- self._pg_encoding = ''
- gDebug (1, "Encoding '%s' is not supported by postgresql dbdriver. "
- "Using default encoding." % self._encoding)
-
-
- # ---------------------------------------------------------------------------
- # Get connection parameters
- # ---------------------------------------------------------------------------
-
- def _getConnectParams (self, connectData):
-
- # mandatory parameters
- kwargs = {'database': connectData ['dbname'],
- 'user' : connectData ['_username'],
- 'password': connectData ['_password']}
-
- # optional parameters
- for gnueName, pgName in [('host', 'host'),
- ('port', 'port')]:
- if connectData.has_key (gnueName):
- kwargs [pgName] = connectData [gnueName]
-
- return ([], kwargs)
-
-
- # ---------------------------------------------------------------------------
- # Done at the start of each transaction
- # ---------------------------------------------------------------------------
-
- def _beginTransaction (self):
-
- # Must set CLIENT_ENCODING per transaction as it is reset on COMMIT or
- # ROLLBACK.
-
- if self._pg_encoding not in ['', 'DEFAULT']:
- self.sql0 ("SET CLIENT_ENCODING TO '%s'" % self._pg_encoding)
-
-
- # ---------------------------------------------------------------------------
- # Return the current date, according to database
- # ---------------------------------------------------------------------------
-
- def getTimeStamp (self):
-
- return self.sql1 ("select current_timestamp")
-
-
- # ---------------------------------------------------------------------------
- # Return a sequence number from sequence 'name'
- # ---------------------------------------------------------------------------
-
- def getSequence (self, name):
-
- return self.sql1 ("select nextval('%s')" % name)
-
-
-# =============================================================================
-# Encoding-Table
-# =============================================================================
-
-pg_encTable = {
- 'ascii' : 'SQL_ASCII', # ASCII
- '' : 'EUC_JP', # Japanese EUC
- '' : 'EUC_CN', # Chinese EUC
- '' : 'EUC_KR', # Korean EUC
- '' : 'JOHAB', # Korean EUC (Hangle base)
- '' : 'EUC_TW', # Taiwan EUC
- 'utf-8' : 'UNICODE', # Unicode (UTF-8)
- '' : 'MULE_INTERNAL', # Mule internal code
- 'iso8859-1' : 'LATIN1', # ISO 8859-1 ECMA-94 Latin Alphabet No.1
- 'iso8859-2' : 'LATIN2', # ISO 8859-2 ECMA-94 Latin Alphabet No.2
- 'iso8859-3' : 'LATIN3', # ISO 8859-3 ECMA-94 Latin Alphabet No.3
- 'iso8859-4' : 'LATIN4', # ISO 8859-4 ECMA-94 Latin Alphabet No.4
- 'iso8859-9' : 'LATIN5', # ISO 8859-9 ECMA-128 Latin Alphabet No.5
- 'iso8859-10': 'LATIN6', # ISO 8859-10 ECMA-144 Latin Alphabet No.6
- 'iso8859-13': 'LATIN7', # ISO 8859-13 Latin Alphabet No.7
- 'iso8859-14': 'LATIN8', # ISO 8859-14 Latin Alphabet No.8
- 'iso8859-15': 'LATIN9', # ISO 8859-15 Latin Alphabet No.9
- 'iso8859-16': 'LATIN10', # ISO 8859-16 ASRO SR 14111 Latin Alph. No.10
- 'iso8859-5' : 'ISO-8859-5', # ECMA-113 Latin/Cyrillic
- 'iso8859-6' : 'ISO-8859-6', # ECMA-114 Latin/Arabic
- 'iso8859-7' : 'ISO-8859-7', # ECMA-118 Latin/Greek
- 'iso8859-8' : 'ISO-8859-8', # ECMA-121 Latin/Hebrew
- 'koi8-r' : 'KOI8', # KOI8-R(U)
- 'cp1251' : 'WIN', # Windows CP1251
- '' : 'ALT', # Windows CP866
- '' : 'WIN1256', # Arabic Windows CP1256
- '' : 'TCVN', # Vietnamese TCVN-5712 (Windows CP1258)
- '' : 'WIN874', # Thai Windows CP874
-}
Deleted: trunk/gnue-common/src/datasources/drivers/postgresql/Behavior.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/postgresql/Behavior.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/postgresql/Behavior.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -1,391 +0,0 @@
-# GNU Enterprise Common Library - PostgreSQL driver - Schema Support
-#
-# Copyright 2001-2005 Free Software Foundation
-#
-# This file is part of GNU Enterprise
-#
-# GNU Enterprise is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General Public
-# License as published by the Free Software Foundation; either
-# version 2, or (at your option) any later version.
-#
-# GNU Enterprise is distributed in the hope that it will be
-# useful, but WITHOUT ANY WARRANTY; without even the implied
-# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with program; see the file COPYING. If not,
-# write to the Free Software Foundation, Inc., 59 Temple Place
-# - Suite 330, Boston, MA 02111-1307, USA.
-#
-# $Id$
-
-import os
-
-from gnue.common.apps import errors
-from gnue.common.datasources.drivers import DBSIG2
-from gnue.common.datasources import GSchema
-
-# =============================================================================
-# Schema support for PostgreSQL backends
-# =============================================================================
-
-class Behavior (DBSIG2.Behavior):
-
- # ---------------------------------------------------------------------------
- # Constructor
- # ---------------------------------------------------------------------------
-
- def __init__ (self, *args, **kwargs):
-
- DBSIG2.Behavior.__init__ (self, *args, **kwargs)
-
- self._RELKIND = {'v': {'type': 'view', 'name': _("Views")},
- 'r': {'type': 'table', 'name': _("Tables")}}
-
- self._maxIdLength = 31
- self._alterMultiple = False
- self._numbers = [[(4, 'smallint'), (9, 'integer'), (18, 'bigint')],
- "numeric (%s,0)", "numeric (%(length)s,%(scale)s)"]
-
- # Build typemap: {nativetype: (group, fieldtype)}
- self._TYPEMAP = {'date' : ('date', 'date'),
- 'bool' : ('boolean', 'boolean'),
- 'string': ('string', 'string')}
-
- for item in ['numeric', 'float4', 'float8', 'money', 'int8',
- 'int2', 'int4', 'serial']:
- self._TYPEMAP [item] = ('number', 'number')
-
- for item in ['time', 'reltime']:
- self._TYPEMAP [item] = ('date', 'time')
-
- for item in ['timestamp', 'abstime']:
- self._TYPEMAP [item] = ('date', 'datetime')
-
- self._type2native.update ({'boolean' : 'boolean',
- 'datetime': 'timestamp without time zone'})
-
-
- # ---------------------------------------------------------------------------
- # Create a new database
- # ---------------------------------------------------------------------------
-
- def createDatabase (self):
- """
- Create the requested user and database using the tools 'createuser',
- 'createdb' and 'dropuser'. Of course this function should better make use
- of the template1 database using a connection object.
- """
-
- dbname = self.__connection.parameters.get ('dbname')
- username = self.__connection.parameters.get ('username', 'gnue')
- password = self.__connection.parameters.get ('password')
- host = self.__connection.parameters.get ('host')
- port = self.__connection.parameters.get ('port')
-
- site = ""
- if host is not None:
- site += " --host=%s" % host
- if port is not None:
- site += " --port=%s" % port
-
- # TODO: use a connection object to the template1 database instead of the
- # shell-scripts. Note: CREATE DATABASE statements must NOT run within a
- # transaction block, so we cannot use the default connection mechanisms.
-
- try:
- os.system (u"dropuser %s%s 2>/dev/null" % (username, site))
-
- except:
- pass
-
- try:
- createuser = u"createuser %s --createdb --adduser %s" % (site, username)
- os.system (createuser)
- except:
- pass
-
- createdb = u"createdb %s --owner=%s --encoding=UNICODE %s" \
- % (site, username, dbname)
-
- if os.system (createdb):
- raise errors.ApplicationError, u_("Database creation failed")
-
-
- self.__connection.manager.loginToConnection (self.__connection)
-
- if password is not None and password:
- alterUser = u"ALTER USER %s WITH PASSWORD '%s';" % (username, password)
- self.__connection.makecursor (alterUser)
- self.__connection.commit ()
-
-
- # ---------------------------------------------------------------------------
- # Read the current connection's schema
- # ---------------------------------------------------------------------------
-
- def _readSchema_ (self, parent):
- """
- Read the connection's schema and build a GSchema object tree connected to
- the given parent object (which is of type GSSchema).
- """
-
- tables = self.__readTables (parent)
- fields = self.__readFields (tables)
- self.__readDefaults (fields)
- self.__readKeys (tables)
- self.__readConstraints (tables, fields)
-
-
- # ---------------------------------------------------------------------------
- # Read all table-like elements
- # ---------------------------------------------------------------------------
-
- def __readTables (self, parent):
-
- mapping = {} # Maps OIDs to GSTable instances
- tables = None
- views = None
-
- cmd = u"SELECT c.oid, c.relname, c.relkind " \
- "FROM pg_class c, pg_namespace n " \
- "WHERE n.nspname = 'public' AND n.oid = c.relnamespace AND " \
- " c.relkind in (%s) " \
- "ORDER BY c.relname" \
- % ','.join (["%r" % kind for kind in self._RELKIND.keys ()])
-
- cursor = self.__connection.makecursor (cmd)
-
- try:
- for (oid, relname, relkind) in cursor.fetchall ():
-
- kind = self._RELKIND [relkind] ['type']
- properties = {'id': oid, 'name': relname, 'kind': kind}
-
- if relkind == 'v':
- if views is None:
- views = GSchema.GSTables (parent, **self._RELKIND [relkind])
- master = views
- else:
- if tables is None:
- tables = GSchema.GSTables (parent, **self._RELKIND [relkind])
- master = tables
-
- table = GSchema.GSTable (master, **properties)
-
- # Maintain a temporary mapping from OID's to GSTable instances so
- # adding fields afterwards runs faster
- mapping [oid] = table
-
- finally:
- cursor.close ()
-
- return mapping
-
-
- # ---------------------------------------------------------------------------
- # Find all fields
- # ---------------------------------------------------------------------------
-
- def __readFields (self, tables):
-
- cmd = u"SELECT attrelid, attname, t.typname, attnotnull, " \
- " atthasdef, atttypmod, attnum, attlen " \
- "FROM pg_attribute a " \
- "LEFT OUTER JOIN pg_type t ON t.oid = a.atttypid " \
- "WHERE attnum >= 0 AND attisdropped = False " \
- "ORDER BY attrelid, attnum"
-
- cursor = self.__connection.makecursor (cmd)
- fields = None
- result = {}
-
- try:
- for rs in cursor.fetchall ():
- (relid, name, typename, notnull, hasdef, typemod, attnum, attlen) = rs
-
- # only process attributes from tables we've listed before
- if not relid in tables:
- continue
-
- attrs = {'id' : "%s.%s" % (relid, attnum),
- 'name' : name,
- 'nativetype': typename,
- 'nullable' : hasdef or not notnull}
-
- if typename.lower () in self._TYPEMAP:
- (group, attrs ['type']) = self._TYPEMAP [typename.lower ()]
- else:
- (group, attrs ['type']) = self._TYPEMAP ['string']
-
- if group == 'number':
- if typemod != -1:
- value = typemod - 4
- attrs ['length'] = value >> 16
- attrs ['precision'] = value & 0xFFFF
-
- elif attlen > 0:
- attrs ['length'] = len ("%s" % 2L ** (attlen * 8))
-
- elif typemod != -1:
- attrs ['length'] = typemod - 4
-
- # Remove obsolete attributes
- if group in ['date', 'boolean']:
- for item in ['length', 'precision']:
- if item in attrs:
- del attrs [item]
-
- elif group in ['string']:
- if 'precision' in attrs:
- del attrs ['precision']
-
- table = tables [relid]
- fields = table.findChildOfType ('GSFields')
- if fields is None:
- fields = GSchema.GSFields (table)
-
- result [attrs ['id']] = GSchema.GSField (fields, **attrs)
-
- finally:
- cursor.close ()
-
- return result
-
-
- # ---------------------------------------------------------------------------
- # Read defaults and apply them to the given fields
- # ---------------------------------------------------------------------------
-
- def __readDefaults (self, fields):
-
- cmd = u"SELECT adrelid, adnum, adsrc FROM pg_attrdef ORDER BY adrelid"
-
- cursor = self.__connection.makecursor (cmd)
-
- try:
- for (relid, fieldnum, source) in cursor.fetchall ():
- field = fields.get ("%s.%s" % (relid, fieldnum))
-
- # Skip all defaults of not listed fields
- if field is None:
- continue
-
- if source [:8] == 'nextval(':
- field.defaultwith = 'serial'
-
- elif source == 'now()':
- field.defaultwith = 'timestamp'
-
- else:
- field.defaultwith = 'constant'
- field.default = source.split ('::') [0].strip ("'")
-
- finally:
- cursor.close ()
-
-
- # ---------------------------------------------------------------------------
- # Read all indices and associate them with their table/view
- # ---------------------------------------------------------------------------
-
- def __readKeys (self, tables):
-
- cmd = u"SELECT indrelid, indkey, indisunique, indisprimary, c.relname " \
- "FROM pg_index i LEFT OUTER JOIN pg_class c ON c.oid = indexrelid"
-
- cursor = self.__connection.makecursor (cmd)
-
- try:
- for (relid, fieldvec, isUnique, isPrimary, name) in cursor.fetchall ():
-
- # Skip functional indices. A functional index is an index that is built
- # upon a fuction manipulating a field upper(userid) vs userid
- fields = [int (i) - 1 for i in fieldvec.split ()]
- if not fields:
- continue
-
- # only process keys of listed tables
- table = tables.get (relid)
- if table is None:
- continue
-
- if isPrimary:
- index = GSchema.GSPrimaryKey (table, name = name)
- fClass = GSchema.GSPKField
- else:
- indices = table.findChildOfType ('GSIndexes')
- if indices is None:
- indices = GSchema.GSIndexes (table)
-
- index = GSchema.GSIndex (indices, unique = isUnique, name = name)
- fClass = GSchema.GSIndexField
-
- fieldList = table.findChildrenOfType ('GSField', False, True)
- for find in fields:
- fClass (index, name = fieldList [find].name)
-
- finally:
- cursor.close ()
-
-
- # ---------------------------------------------------------------------------
- # Read all constraints
- # ---------------------------------------------------------------------------
-
- def __readConstraints (self, tables, fields):
-
- cmd = u"SELECT conname, conrelid, confrelid, conkey, confkey " \
- "FROM pg_constraint WHERE contype = 'f'"
-
- cursor = self.__connection.makecursor (cmd)
- try:
- for (name, relid, fkrel, key, fkey) in cursor.fetchall ():
- table = tables.get (relid)
- fktable = tables.get (fkrel)
-
- # We need both ends of a relation to be a valid constraint
- if table is None or fktable is None:
- continue
-
- parent = table.findChildOfType ('GSConstraints')
- if parent is None:
- parent = GSchema.GSConstraints (table)
-
- constr = GSchema.GSForeignKey (parent, name = name,
- references = fktable.name)
-
- kp = isinstance (key, basestring) and key [1:-1].split (',') or key
- fkp = isinstance (fkey, basestring) and fkey [1:-1].split (',') or fkey
-
- k = [fields ["%s.%s" % (relid, i)].name for i in kp]
- f = [fields ["%s.%s" % (fkrel, i)].name for i in fkp]
-
- for (name, refname) in zip (k, f):
- GSchema.GSFKField (constr, name = name, references = refname)
-
- finally:
- cursor.close ()
-
-
- # ---------------------------------------------------------------------------
- # Handle special defaults
- # ---------------------------------------------------------------------------
-
- def _defaultwith_ (self, code, field):
- """
- Create a sequence for 'serials' and set the default for 'timestamps'.
-
- @param code: code-triple to get the result
- @param field: GSField instance of the field having the default
- """
-
- if field.defaultwith == 'serial':
- seq = self._getSequenceName_ (field)
- code [0].append (u"CREATE SEQUENCE %s" % seq)
- field.default = "DEFAULT nextval ('%s')" % seq
-
- elif field.defaultwith == 'timestamp':
- field.default = "DEFAULT now()"
Deleted: trunk/gnue-common/src/datasources/drivers/postgresql/__init__.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/postgresql/__init__.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/postgresql/__init__.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -1,46 +0,0 @@
-#
-# This file is part of GNU Enterprise.
-#
-# GNU Enterprise is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General Public
-# License as published by the Free Software Foundation; either
-# version 2, or(at your option) any later version.
-#
-# GNU Enterprise is distributed in the hope that it will be
-# useful, but WITHOUT ANY WARRANTY; without even the implied
-# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with program; see the file COPYING. If not,
-# write to the Free Software Foundation, Inc., 59 Temple Place
-# - Suite 330, Boston, MA 02111-1307, USA.
-#
-# Copyright 2000-2005 Free Software Foundation
-#
-"""
-Driver structure for PostgreSQL databases.
-"""
-
-# Define alias for plugin loader
-__pluginalias__ = ['pgsql', 'postgres']
-
-
-# =============================================================================
-# Driver info
-# =============================================================================
-
-class DriverInfo:
- name = "PostgreSQL (7.x+)"
- url = "http://www.postgresql.org/"
- description = """
-PostgreSQL is an free object-relational database, which supports a large part
-of SQL-99. It is under continuous development and each release implements
-more of the SQL standard, to the extent that it is now probably more compliant
-than most commercial databases. It also supports some object-oriented
-features. PostgreSQL is a full-featured, multi-user RDBMS that scales well
-from a few users to an entire organization.
-
-PostgreSQL is the primary database used by GNUe developers.
-"""
- isfree = True
Deleted: trunk/gnue-common/src/datasources/drivers/postgresql/psycopg/Driver.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/postgresql/psycopg/Driver.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/postgresql/psycopg/Driver.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -1,37 +0,0 @@
-# GNU Enterprise Common Library - Postgres DB driver using psycopg
-#
-# Copyright 2001-2005 Free Software Foundation
-#
-# This file is part of GNU Enterprise
-#
-# GNU Enterprise is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General Public
-# License as published by the Free Software Foundation; either
-# version 2, or (at your option) any later version.
-#
-# GNU Enterprise is distributed in the hope that it will be
-# useful, but WITHOUT ANY WARRANTY; without even the implied
-# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with program; see the file COPYING. If not,
-# write to the Free Software Foundation, Inc., 59 Temple Place
-# - Suite 330, Boston, MA 02111-1307, USA.
-#
-# $Id$
-
-__all__ = ('Connection')
-
-from gnue.common.datasources.drivers.postgresql import Base
-
-
-# =============================================================================
-# PostgreSQL Connection class using psycopg
-# =============================================================================
-
-class Connection (Base.Connection):
- """
- Connection class for PostgreSQL databases using the psycopg DBSIG2 driver.
- """
- _drivername = 'psycopg'
Modified:
trunk/gnue-common/src/datasources/drivers/postgresql/psycopg/__init__.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/postgresql/psycopg/__init__.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/postgresql/psycopg/__init__.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -28,62 +28,3 @@
"""
from Driver import Connection
-
-
-# -----------------------------------------------------------------------------
-# Test if plugin is functional
-# -----------------------------------------------------------------------------
-
-def __initplugin__ ():
- from gnue.common.datasources import GConnections
- try:
- import psycopg
- except:
- raise GConnections.DependencyError, ('psycopg', None)
-
-
-# -----------------------------------------------------------------------------
-# Driver info
-# -----------------------------------------------------------------------------
-
-class DriverInfo:
- name = "Psycopg"
- url = "http://initd.org/software/initd/psycopg/"
- doc = """
-Description
------------
-From the Psycopg website: "It was written from scratch with the aim of
-being very small and fast, and stable as a rock." Written by initd.org
-volunteers.
-
-Support
--------
-Supported Platforms:
-
- - Linux/BSD
- - MS Windows 98/NT/2000/XP (Installer available)
-
-Connection Properties
----------------------
-* dbname -- This is the database to use (required)
-* host -- This is the name of the database host, or, on Linux,
- directory containing the network socket (optional)
-* port -- Port that PostgreSQL is running on (defaults to 5432) (optional)
-
-Examples
---------
- [myconn]
- provider=psycopg # Use the psycopg adapter
- host=localhost # The hostname/IP of the postgresql host
- dbname=mydb # The name of the pg database
-
-Notes
------
-1. This is the driver of choice for PostgreSQL.
-
-2. Available in Debian as: "apt-get install python-psycopg".
-
-3. Windows installer available at:
http://stickpeople.com/projects/python/win-psycopg/.
-
-4. This driver is fully functional with no known serious problems.
-"""
Deleted: trunk/gnue-common/src/datasources/drivers/postgresql/pygresql/Driver.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/postgresql/pygresql/Driver.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/postgresql/pygresql/Driver.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -1,37 +0,0 @@
-# GNU Enterprise Common Library - Postgres DB driver using PyGreSQL
-#
-# Copyright 2001-2005 Free Software Foundation
-#
-# This file is part of GNU Enterprise
-#
-# GNU Enterprise is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General Public
-# License as published by the Free Software Foundation; either
-# version 2, or (at your option) any later version.
-#
-# GNU Enterprise is distributed in the hope that it will be
-# useful, but WITHOUT ANY WARRANTY; without even the implied
-# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with program; see the file COPYING. If not,
-# write to the Free Software Foundation, Inc., 59 Temple Place
-# - Suite 330, Boston, MA 02111-1307, USA.
-#
-# $Id$
-
-__all__ = ('Connection')
-
-from gnue.common.datasources.drivers.postgresql import Base
-
-
-# =============================================================================
-# PostgreSQL Connection class using PyGreSQL
-# =============================================================================
-
-class Connection (Base.Connection):
- """
- Connection class for PostgreSQL databases using the PyGreSQL DBSIG2 driver.
- """
- _drivername = 'pgdb'
Modified:
trunk/gnue-common/src/datasources/drivers/postgresql/pygresql/__init__.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/postgresql/pygresql/__init__.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/postgresql/pygresql/__init__.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -28,55 +28,3 @@
"""
from Driver import Connection
-
-
-# -----------------------------------------------------------------------------
-# Test if plugin is functional
-# -----------------------------------------------------------------------------
-
-def __initplugin__ ():
- from gnue.common.datasources import GConnections
- try:
- import pgdb
- except ImportError:
- raise GConnections.DependencyError, ('pygresql', None)
-
-
-# -----------------------------------------------------------------------------
-# Driver info
-# -----------------------------------------------------------------------------
-
-class DriverInfo:
- name = "PyGreSQL"
- url = "http://druid.net/pygresql/"
- doc = """
-Description
------------
-PyGreSQL is the PostgreSQL-Python driver available via PostgreSQL's CVS tree.
-It is compliant to Python's DB-API 2.0.
-
-Support
--------
-Supported Platforms:
-
- - Linux/BSD
-
-Connection Properties
----------------------
-* dbname -- This is the database to use (required)
-* host -- This is the name of the database host, or, on Linux,
- directory containing the network socket (optional)
-* port -- Port that PostgreSQL is running on (defaults to 5432) (optional)
-
-Examples
---------
- [myconn]
- provider=pygresql # Use the pygresql adapter
- host=localhost # The hostname/IP of the postgresql host
- dbname=mydb # The name of the pg database
-
-Notes
------
-1. The developers of GNUe have had mixed results with the PygreSQL driver
- and generally recommend one of the others.
-"""
Deleted: trunk/gnue-common/src/datasources/drivers/postgresql/pypgsql/Driver.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/postgresql/pypgsql/Driver.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/postgresql/pypgsql/Driver.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -1,40 +0,0 @@
-# GNU Enterprise Common Library - Postgres DB driver using pyPgSQL
-#
-# Copyright 2001-2005 Free Software Foundation
-#
-# This file is part of GNU Enterprise
-#
-# GNU Enterprise is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General Public
-# License as published by the Free Software Foundation; either
-# version 2, or (at your option) any later version.
-#
-# GNU Enterprise is distributed in the hope that it will be
-# useful, but WITHOUT ANY WARRANTY; without even the implied
-# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with program; see the file COPYING. If not,
-# write to the Free Software Foundation, Inc., 59 Temple Place
-# - Suite 330, Boston, MA 02111-1307, USA.
-#
-# $Id$
-
-__all__ = ('Connection')
-
-from gnue.common.datasources.drivers.postgresql import Base
-
-
-# =============================================================================
-# PostgreSQL Connection class using pyPgSQL
-# =============================================================================
-
-class Connection (Base.Connection):
- """
- Connection class for PostgreSQL databases using the pyPgSQL DBSIG2 driver.
- """
- _drivername = 'pyPgSQL.PgSQL'
- _rowidField = None # PyPgSQL doesn't support rowid's!!
- _broken_fetchmany = True
- _broken_rowcount = True
Modified:
trunk/gnue-common/src/datasources/drivers/postgresql/pypgsql/__init__.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/postgresql/pypgsql/__init__.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/postgresql/pypgsql/__init__.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -28,61 +28,3 @@
"""
from Driver import Connection
-
-
-# -----------------------------------------------------------------------------
-# Test if plugin is functional
-# -----------------------------------------------------------------------------
-
-def __initplugin__ ():
- from gnue.common.datasources import GConnections
- try:
- from pyPgSQL import PgSQL
- except:
- raise GConnections.DependencyError, ('pyPgSQL', None)
-
-
-# -----------------------------------------------------------------------------
-# Driver info
-# -----------------------------------------------------------------------------
-
-class DriverInfo:
- name = "pyPgSQL"
- url = "http://pypgsql.sf.net/"
- doc = """
-Description
------------
-Written by Billy Allie, pyPgSQL is a database interface for PostgreSQL 7.x.
-
-Support
--------
-Supported Platforms:
-
- - Linux/BSD
- - MS Windows 98/NT/2000/XP (Installer available)
-
-Platforms Tested:
-
- - GNU/Linux [Debian 2.x, 3.x, Slackware 8.0, RedHat ]
- - Windows 98/2000/XP
-
-Connection Properties
----------------------
-* dbname -- This is the database to use (required)
-* host -- This is the name of the database host, or, on Linux,
- directory containing the network socket (optional)
-* port -- Port that PostgreSQL is running on (defaults to 5432) (optional)
-
-Examples
---------
- [myconn]
- provider=pypgsql # Use the pypgsql adapter
- host=localhost # The hostname/IP of the postgresql host
- dbname=mydb # The name of the pg database
-
-Notes
------
-1. pyPgSQL is available in Debian as python-pgsql.
-
-2. This driver is fully functional with no known serious problems.
-"""
Added: trunk/gnue-common/src/datasources/drivers/sql/__init__.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/sql/__init__.py 2005-06-18
11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/sql/__init__.py 2005-06-20
09:40:30 UTC (rev 7619)
@@ -0,0 +1,33 @@
+# GNU Enterprise Common Library - Database drivers for SQL based backends
+#
+# Copyright 2000-2005 Free Software Foundation
+#
+# This file is part of GNU Enterprise.
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id: __init__.py 7615 2005-06-17 15:24:00Z reinhard $
+
+"""
+Database driver plugins for SQL based backends.
+"""
+
+# =============================================================================
+# Driver info
+# =============================================================================
+
+class DriverInfo:
+ name = "SQL based backends"
Copied: trunk/gnue-common/src/datasources/drivers/sql/interbase/Behavior.py
(from rev 7618, trunk/gnue-common/src/datasources/drivers/interbase/Behavior.py)
===================================================================
--- trunk/gnue-common/src/datasources/drivers/interbase/Behavior.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/sql/interbase/Behavior.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -0,0 +1,442 @@
+# GNU Enterprise Common Library - Interbase/Firebird driver - Schema support
+#
+# Copyright 2001-2005 Free Software Foundation
+#
+# This file is part of GNU Enterprise
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+
+import re
+
+from gnue.common.datasources.GLoginHandler import BasicLoginHandler
+from gnue.common.datasources.drivers import DBSIG2
+from gnue.common.datasources import GSchema
+
+# =============================================================================
+# Schema support for Interbase/Firebird database backends
+# =============================================================================
+
+class Behavior (DBSIG2.Behavior):
+ """
+ Limitations:
+ - Interbase/Firebird has no native boolean datatype. That's why this
+ introspection module treats the domain 'BOOLEAN' as boolean data types.
+ """
+
+ # ---------------------------------------------------------------------------
+ # Constructor
+ # ---------------------------------------------------------------------------
+
+ def __init__ (self, connection):
+
+ DBSIG2.Behavior.__init__ (self, connection)
+
+ self._RELTYPE = {False: {'type': 'table', 'name': _('Tables')},
+ True : {'type': 'view' , 'name': _('Views')}}
+
+ self._TYPEMAP = {'DATE': 'date', 'TIME': 'time', 'TIMESTAMP': 'datetime'}
+ self._NOW = re.compile ("'(NOW\s*\(\)\s*)'", re.IGNORECASE)
+ self._GENFIELD = re.compile ('^.*NEW\.(\w+)\s*=\s*GEN_ID\s*\(.*\)',
+ re.IGNORECASE)
+
+ self._maxIdLength = 31
+ self._alterMultiple = False
+ self._maxVarchar = 10921
+ self._numbers = [[(4, 'SMALLINT'), (9, 'INTEGER')], "NUMERIC(%s)",
+ "NUMERIC (%(length)s,%(scale)s)"]
+
+ self._type2native ['datetime'] = 'timestamp'
+ self._type2native ['boolean'] = 'boolean'
+
+
+ # ---------------------------------------------------------------------------
+ # Create a new database
+ # ---------------------------------------------------------------------------
+
+ def createDatabase (self):
+ """
+ Create a new database for the associated connection. The password for the
+ SYSDBA will be queried.
+ """
+
+ dbname = self.__connection.parameters.get ('dbname', None)
+ username = self.__connection.parameters.get ('username', 'gnue')
+ password = self.__connection.parameters.get ('password', 'gnue')
+ host = self.__connection.parameters.get ('host', None)
+ gsecbin = self.__connection.parameters.get ('gsecbin', 'gsec')
+
+ loginHandler = BasicLoginHandler ()
+ fields = [(u_("Password"), '_password', 'password', None, None, [])]
+ title = u_("Logon for SYSDBA into Security Database")
+
+ error = None
+ res = {'_password': ''}
+ while not res ['_password']:
+ res = loginHandler.askLogin (title, fields, {}, error)
+ if not res ['_password']:
+ error = u_("Please specify a password")
+
+ syspw = res ['_password']
+
+ if host:
+ dburl = "%s:%s" % (host, dbname)
+ else:
+ dburl = dbname
+
+ code = u"%s -user sysdba -password %s -delete %s" % \
+ (gsecbin, syspw, username)
+
+ try:
+ os.system (code)
+ except:
+ pass
+
+ code = u"%s -user sysdba -password %s -add %s -pw %s" % \
+ (gsecbin, syspw, username, password)
+
+ try:
+ # if creating the user fails we try to create the db anyway. Maybe this
+ # is done from a remote system where no gsec is available, but the given
+ # credentials are valid on the given server.
+ os.system (code)
+ except:
+ pass
+
+ self.__connection._driver.create_database (\
+ u"create database '%s' user '%s' password '%s' " \
+ "default character set UNICODE_FSS" % (dburl, username, password))
+
+ self.__connection.manager.loginToConnection (self.__connection)
+
+ code = u"CREATE DOMAIN boolean AS smallint " \
+ "CHECK (value IN (0,1) OR value IS NULL);"
+ self.__connection.makecursor (code)
+
+ code = u"DECLARE EXTERNAL FUNCTION lower CSTRING(255) " \
+ "RETURNS CSTRING(255) FREE_IT " \
+ "ENTRY_POINT 'IB_UDF_lower' MODULE_NAME 'ib_udf';"
+ self.__connection.makecursor (code)
+ self.__connection.commit ()
+
+ # ---------------------------------------------------------------------------
+ # Read the current connection's schema
+ # ---------------------------------------------------------------------------
+
+ def _readSchema_ (self, parent):
+ """
+ """
+
+ tables = self.__readTables (parent)
+ fields = self.__readFields (tables)
+ constr = self.__readConstraints (tables)
+ self.__readKeys (tables, constr)
+ self.__readSerials (tables)
+
+
+ # --------------------------------------------------------------------------
+ # Read all tables and views
+ # --------------------------------------------------------------------------
+
+ def __readTables (self, parent):
+
+ cmd = u"SELECT rdb$relation_name, rdb$view_source FROM RDB$RELATIONS " \
+ "WHERE rdb$system_flag = 0 ORDER BY rdb$relation_name"
+
+ result = {}
+ masters = {}
+ cursor = self.__connection.makecursor (cmd)
+
+ for rs in cursor.fetchall ():
+ (name, source) = self.__stripStrings (rs)
+ reltype = self._RELTYPE [source is not None]
+ if not reltype ['type'] in masters:
+ masters [reltype ['type']] = GSchema.GSTables (parent, **reltype)
+
+ result [name] = GSchema.GSTable (masters [reltype ['type']], name = name)
+
+ return result
+
+
+ # ---------------------------------------------------------------------------
+ # Read all fields of the given tables
+ # ---------------------------------------------------------------------------
+
+ def __readFields (self, tables):
+
+ result = {}
+
+ cmd = u"SELECT rf.rdb$relation_name, rf.rdb$field_name, tp.rdb$type_name,"
\
+ " rf.rdb$null_flag, rf.rdb$default_source, fs.rdb$field_length, " \
+ " fs.rdb$field_scale, fs.rdb$field_precision, " \
+ " fs.rdb$character_length, rf.rdb$field_source " \
+ "FROM rdb$relation_fields rf, rdb$fields fs, rdb$types tp " \
+ "WHERE " \
+ "fs.rdb$field_name = rf.rdb$field_source AND " \
+ "tp.rdb$type = fs.rdb$field_type AND " \
+ "tp.rdb$field_name = 'RDB$FIELD_TYPE'" \
+ "ORDER BY rf.rdb$relation_name, rf.rdb$field_position"
+
+ cursor = self.__connection.makecursor (cmd)
+ try:
+ for rs in cursor.fetchall ():
+ (table, name, ftype, null, default, flen, scale, prec, clen, fsrc) = \
+ self.__stripStrings (rs)
+
+ if not table in tables:
+ continue
+
+ nativetype = ftype
+ attrs = {'id' : "%s.%s" % (table, name),
+ 'name' : name,
+ 'nativetype': nativetype,
+ 'nullable' : not null}
+
+ if fsrc == 'BOOLEAN':
+ attrs ['type'] = 'boolean'
+
+ elif nativetype in self._TYPEMAP:
+ attrs ['type'] = self._TYPEMAP [nativetype]
+
+ elif nativetype in ['DOUBLE', 'FLOAT', 'INT64', 'LONG', 'QUAD', \
+ 'SHORT']:
+ attrs ['type'] = 'number'
+ if prec == 0 and scale == 0:
+ attrs ['length'] = len ("%s" % 2L ** (flen * 8))
+ else:
+ attrs ['length'] = prec
+ attrs ['precision'] = abs (scale)
+
+ else:
+ attrs ['type'] = 'string'
+ attrs ['length'] = clen
+
+ if default is not None:
+ if self._NOW.search (default) is not None:
+ attrs ['defaultwith'] = 'timestamp'
+ else:
+ attrs ['defaultwith'] = 'constant'
+ attrs ['defaultl'] = default [8:]
+
+ fields = tables [table].findChildOfType ('GSFields') or \
+ GSchema.GSFields (tables [table])
+
+ result [attrs ['id']] = GSchema.GSField (fields, **attrs)
+
+ finally:
+ cursor.close ()
+
+ return result
+
+
+ # ---------------------------------------------------------------------------
+ # Read all relation constraints (pk/fk only)
+ # ---------------------------------------------------------------------------
+
+ def __readConstraints (self, tables):
+
+ cmd = u"SELECT rdb$relation_name, rdb$constraint_name, " \
+ " rdb$constraint_type, rdb$index_name " \
+ "FROM rdb$relation_constraints " \
+ "WHERE rdb$constraint_type IN ('PRIMARY KEY', 'FOREIGN KEY') "
+
+ result = {}
+ cursor = self.__connection.makecursor (cmd)
+ try:
+ for rs in cursor.fetchall ():
+ (tname, name, ctype, index) = self.__stripStrings (rs)
+
+ table = tables.get (tname)
+ if table is None:
+ continue
+
+ if ctype == 'PRIMARY KEY':
+ item = GSchema.GSPrimaryKey (table, name = name)
+ else:
+ cons = table.findChildOfType ('GSConstraints') or \
+ GSchema.GSConstraints (table)
+ item = GSchema.GSForeignKey (cons, name = name)
+
+ result ["%s.%s" % (tname, index)] = item
+
+ finally:
+ cursor.close ()
+
+ return result
+
+
+ # ---------------------------------------------------------------------------
+ # Read indices and populate constraints
+ # ---------------------------------------------------------------------------
+
+ def __readKeys (self, tables, constraints):
+
+ fields = {} # Map index to fields
+ relmap = {} # Map index to relations
+ update = {} # Map FK-Relations to be updated after the first run
+
+ # First build a mapping of all index fields
+ cmd = u"SELECT rdb$index_name, rdb$field_name FROM rdb$index_segments " \
+ "ORDER BY rdb$index_name, rdb$field_position"
+
+ cursor = self.__connection.makecursor (cmd)
+
+ try:
+ for (index, field) in cursor.fetchall ():
+ seq = fields.setdefault (index.strip (), [])
+ seq.append (field.strip ())
+
+ finally:
+ cursor.close ()
+
+ # Now build up the indices and populate the constraints
+ cmd = u"SELECT rdb$index_name, rdb$relation_name, rdb$unique_flag, " \
+ " rdb$foreign_key " \
+ "FROM rdb$indices " \
+ "WHERE (rdb$index_inactive IS NULL or rdb$index_inactive = 0) " \
+ "ORDER BY rdb$relation_name, rdb$index_id"
+
+ cursor = self.__connection.makecursor (cmd)
+ try:
+ for rs in cursor.fetchall ():
+ (iname, tname, unique, fkey) = self.__stripStrings (rs)
+ if not tname in tables:
+ continue
+
+ relmap [iname] = tname
+ table = tables [tname]
+
+ constraint = constraints.get ("%s.%s" % (tname, iname))
+ if constraint is None:
+ ind = table.findChildOfType ('GSIndexes') or GSchema.GSIndexes
(table)
+ index = GSchema.GSIndex (ind, name = iname, unique = unique == 1)
+
+ for field in fields [iname]:
+ GSchema.GSIndexField (index, name = field)
+ else:
+ if isinstance (constraint, GSchema.GSPrimaryKey):
+ for field in fields [iname]:
+ GSchema.GSPKField (constraint, name = field)
+ else:
+ for (field, reffield) in zip (fields [iname], fields [fkey]):
+ GSchema.GSFKField (constraint, name = field,
+ references = reffield)
+ update.setdefault (fkey, []).append (constraint)
+
+ for (fkey, constraints) in update.items ():
+ for item in constraints:
+ item.references = relmap [fkey]
+
+ finally:
+ cursor.close ()
+
+
+ # ---------------------------------------------------------------------------
+ # Read all 'before insert'-triggers to discover Generator based fields
+ # ---------------------------------------------------------------------------
+
+ def __readSerials (self, tables):
+
+ cmd = u"SELECT rdb$relation_name, rdb$trigger_source " \
+ "FROM rdb$triggers " \
+ "WHERE rdb$trigger_type = 1 " \
+ "ORDER BY rdb$trigger_sequence"
+ cursor = self.__connection.makecursor (cmd)
+
+ try:
+ for rs in cursor.fetchall ():
+ (relname, source) = self.__stripStrings (rs)
+ if not relname in tables:
+ continue
+
+ match = self._GENFIELD.match (source)
+ if match is not None:
+ fieldname = match.groups () [0].upper ()
+ fields = tables [relname].findChildrenOfType ('GSField', False, True)
+ for item in fields:
+ if item.name == fieldname:
+ item.defaultwith = 'serial'
+
+ finally:
+ cursor.close ()
+
+
+ # ---------------------------------------------------------------------------
+ # Strip all 'stripable' elements in a given sequence
+ # ---------------------------------------------------------------------------
+
+ def __stripStrings (self, seq):
+
+ result = []
+ append = result.append
+
+ for item in seq:
+ if hasattr (item, 'strip'):
+ append (item.strip ())
+ else:
+ append (item)
+
+ return result
+
+
+ # ---------------------------------------------------------------------------
+ # Process a defaultwith attribute
+ # ---------------------------------------------------------------------------
+
+ def _defaultwith_ (self, code, field):
+ """
+ Process special kinds of default values like sequences, functions and so
+ on. Defaults of type 'constant' are already handled by '_processFields_'.
+
+ @param code: code-triple of the current field as built by _processFields_
+ @param field: GSField instance to process the default for
+ """
+
+ if field.defaultwith == 'serial':
+ table = field.findParentOfType ('GSTable')
+ seq = self._getSequenceName_ (field)
+
+ code [0].append (u"CREATE GENERATOR %s" % seq)
+ code [2].append ( \
+ u"CREATE TRIGGER trg_%s FOR %s ACTIVE BEFORE INSERT POSITION 0 AS " \
+ "BEGIN IF (NEW.%s IS NULL) THEN NEW.%s = GEN_ID (%s,1); END" \
+ % (field.name, table.name, field.name, field.name, seq))
+
+ elif field.defaultwith == 'timestamp':
+ field.default = "NOW"
+
+
+ # ---------------------------------------------------------------------------
+ # Create a native type representation for strings
+ # ---------------------------------------------------------------------------
+
+ def string (self, field):
+ """
+ Return the native datatype for a string-field.
+
+ @param field: GSField instance to get the native datatype for
+ @return: string with the native datatype
+ """
+
+ if hasattr (field, 'length') and field.length <= self._maxVarchar:
+ return "varchar (%s)" % field.length
+
+ elif not hasattr (field, 'length'):
+ return "varchar (%s)" % self._maxVarchar
+
+ else:
+ return "blob"
Added: trunk/gnue-common/src/datasources/drivers/sql/interbase/__init__.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/sql/interbase/__init__.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/sql/interbase/__init__.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -0,0 +1,56 @@
+# GNU Enterprise Common Library - Firebird/Interbase DB Driver
+#
+# Copyright 2000-2005 Free Software Foundation
+#
+# This file is part of GNU Enterprise.
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id: csvfile.py 7615 2005-06-17 15:24:00Z reinhard $
+
+"""
+Database driver plugin for Firebird and Interbase backends.
+"""
+
+# =============================================================================
+# Define alias for 'firebird'
+# =============================================================================
+
+__pluginalias__ = ['firebird']
+
+
+# =============================================================================
+# Driver info
+# =============================================================================
+
+class DriverInfo:
+ name = "Firebird/Interbase"
+ url = "http://www.firebirdsql.org/"
+ description = """
+Firebird is a free relational database offering many ANSI SQL-92 features that
+runs on GNU/Linux, Windows, and a variety of Unix platforms. Firebird offers
+excellent concurrency, high performance, and powerful language support for
+stored procedures and triggers. It has been used in production systems,
+under a variety of names since 1981.
+
+Interbase is a proprietary database available from Borland.
+
+Firebird and Interbase share a common API, which allows GNUe to use the same
+drivers for both.
+
+Firebird is a popular choice of GNUe's Windows-based developers.
+"""
+ isfree = True
Copied: trunk/gnue-common/src/datasources/drivers/sql/interbase/kinterbasdb.py
(from rev 7618,
trunk/gnue-common/src/datasources/drivers/interbase/interbase/Connection.py)
===================================================================
--- trunk/gnue-common/src/datasources/drivers/interbase/interbase/Connection.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/sql/interbase/kinterbasdb.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -0,0 +1,213 @@
+# GNU Enterprise Common Library - Interbase DB Driver
+#
+# Copyright 2001-2005 Free Software Foundation
+#
+# This file is part of GNU Enterprise
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+
+"""
+Database driver plugin for Firebird/Interbase using kinterbasdb.
+"""
+
+__all__ = ['Connection']
+
+from gnue.common.datasources.drivers import DBSIG2
+from gnue.common.datasources.drivers.sql.interbase import Behavior
+
+
+# =============================================================================
+# Test if plugin is functional
+# =============================================================================
+
+def __initplugin__ ():
+ from gnue.common.datasources import GConnections
+ try:
+ import kinterbasdb
+ except ImportError:
+ raise GConnections.DependencyError, ('Kinterbasdb', None)
+
+
+# =============================================================================
+# Driver info
+# =============================================================================
+
+class DriverInfo:
+
+ name = "kinterbasdb Firebird/Interbase Driver"
+
+ url = "http://kinterbasdb.sourceforge.net"
+
+ doc = """
+Description
+-----------
+Written by Alexander Kuznetsov, kinterbasdb provides support for
+Firebird and Interbase.
+
+Support
+-------
+Supported Platforms:
+
+ - Linux/BSD
+ - MS Windows 98/NT/2000/XP (Installer available)
+
+
+Connection Properties
+---------------------
+* host -- This is the hostname running your database server (optional)
+* dbname -- This is the name of the database to use (required)
+
+Examples
+--------
+ [myconn]
+ provider=firebird # Use the kinterbasdb adapter
+ host=localhost # The hostname/IP of the Firebird host
+ dbname=mydb # The name of the Firebird database
+
+ [myconn2]
+ provider=interbase # Use the kinterbasdb adapter
+ host=localhost # The hostname/IP of the Interbase host
+ dbname=mydb # The name of the Interbase database
+
+Notes
+-----
+1. This driver is fully fuctional and has no serious known problems.
+"""
+
+
+# =============================================================================
+# Interbase Connection class
+# =============================================================================
+
+class Connection (DBSIG2.Connection):
+ """
+ Connection class for Interbase databases.
+ """
+
+ _drivername = 'kinterbasdb'
+ _behavior = Behavior.Behavior
+
+ _broken_rowcount = True
+
+
+ # ---------------------------------------------------------------------------
+ # Constructor
+ # ---------------------------------------------------------------------------
+
+ def __init__ (self, connections, name, parameters):
+
+ DBSIG2.Connection.__init__ (self, connections, name, parameters)
+
+ # Find out encoding for Interbase
+ if ib_encTable.has_key (self._encoding):
+ self._ib_encoding = ib_encTable [self._encoding]
+ else:
+ self._ib_encoding = ''
+ gDebug (1, "Encoding '%s' is not supported by interbase dbdriver. "
+ "Using default encoding." % self._encoding)
+
+
+ # ---------------------------------------------------------------------------
+ # Get connection parameters
+ # ---------------------------------------------------------------------------
+
+ def _getConnectParams (self, connectData):
+
+ # mandatory parameters
+ kwargs = {'database': connectData ['dbname'],
+ 'user' : connectData ['_username'],
+ 'password': connectData ['_password']}
+
+ # optional parameters
+ for gnueName, ibName in [('host', 'host')]:
+ if connectData.has_key (gnueName):
+ kwargs [ibName] = connectData [gnueName]
+
+ # character set
+ if self._ib_encoding:
+ kwargs ['charset'] = self._ib_encoding
+
+ return ([], kwargs)
+
+
+ # ---------------------------------------------------------------------------
+ # Start a new transaction
+ # ---------------------------------------------------------------------------
+
+ def _beginTransaction (self):
+ self._native.begin ()
+
+
+ # ---------------------------------------------------------------------------
+ # Return the current date, according to database
+ # ---------------------------------------------------------------------------
+
+ def getTimeStamp (self):
+ return self.sql1 ("SELECT CAST('now' AS DATE) FROM rdb$database")
+
+
+ # ---------------------------------------------------------------------------
+ # Return a sequence number from sequence 'name'
+ # ---------------------------------------------------------------------------
+
+ def getSequence (self, name):
+ return self.sql1 ("SELECT gen_id(%s,1) FROM rdb$database" % name)
+
+
+# =============================================================================
+# Encoding-Table
+# =============================================================================
+
+# RDB$CHARACTER_SETS.RDB$CHARACTER_SET_NAME
+ib_encTable = {'ascii' : 'ASCII',
+ '' : 'BIG_5',
+ '' : 'CYRL',
+ 'cp437' : 'DOS437',
+ 'cp850' : 'DOS850',
+ 'cp852' : 'DOS852',
+ 'cp857' : 'DOS857',
+ 'cp860' : 'DOS860',
+ 'cp861' : 'DOS861',
+ 'cp863' : 'DOS863',
+ 'cp865' : 'DOS865',
+ '' : 'EUCJ_0208',
+ '' : 'GB_2312',
+ 'iso8859-1' : 'ISO8859_1',
+ 'iso8859-2' : 'ISO8859_2',
+ 'iso8859-3' : 'ISO8859_3',
+ 'iso8859-4' : 'ISO8859_4',
+ 'iso8859-5' : 'ISO8859_5',
+ 'iso8859-6' : 'ISO8859_6',
+ 'iso8859-7' : 'ISO8859_7',
+ 'iso8859-8' : 'ISO8859_8',
+ 'iso8859-9' : 'ISO8859_9',
+ 'iso8859-13': 'ISO8859_13',
+ '' : 'KSC_5601',
+ '' : 'NEXT',
+ '' : 'NONE',
+ '' : 'OCTETS',
+ '' : 'SJIS_0208',
+ 'utf-8' : 'UNICODE_FSS',
+ 'cp1250' : 'WIN1250',
+ 'cp1251' : 'WIN1251',
+ 'cp1252' : 'WIN1252',
+ 'cp1253' : 'WIN1253',
+ 'cp1254' : 'WIN1254',
+ 'cp1255' : 'WIN1255',
+ 'cp1256' : 'WIN1256',
+ 'cp1257' : 'WIN1257'}
Copied: trunk/gnue-common/src/datasources/drivers/sql/maxdb/Behavior.py (from
rev 7618, trunk/gnue-common/src/datasources/drivers/maxdb/Behavior.py)
Copied: trunk/gnue-common/src/datasources/drivers/sql/maxdb/__init__.py (from
rev 7618, trunk/gnue-common/src/datasources/drivers/maxdb/__init__.py)
===================================================================
--- trunk/gnue-common/src/datasources/drivers/maxdb/__init__.py 2005-06-18
11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/sql/maxdb/__init__.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -0,0 +1,52 @@
+# GNU Enterprise Common Library - MaxDB/SAP-DB DB Driver
+#
+# Copyright 2000-2005 Free Software Foundation
+#
+# This file is part of GNU Enterprise.
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+
+"""
+Database driver plugin for MaxDB and SAP-DB backends.
+"""
+
+# =============================================================================
+# Define alias for 'firebird'
+# =============================================================================
+
+__pluginalias__ = ['sapdb']
+
+
+# =============================================================================
+# Driver info
+# =============================================================================
+
+class DriverInfo:
+
+class DriverInfo:
+ name = "MaxDB (formerly SAP-DB)"
+ url = "http://www.mysql.com/products/maxdb/"
+ description = """
+MySQL's MaxDB is an enhanced version of SAP DB, SAP AG's open source
+database. MaxDB is a heavy-duty, SAP-certified open source database
+that offers high availability, scalability and a comprehensive
+feature set.
+
+MaxDB is licensed under both the GPL and a fee-based, commercial license.
+"""
+ isfree = True
Copied: trunk/gnue-common/src/datasources/drivers/sql/maxdb/maxdb.py (from rev
7618, trunk/gnue-common/src/datasources/drivers/maxdb/maxdb/Connection.py)
===================================================================
--- trunk/gnue-common/src/datasources/drivers/maxdb/maxdb/Connection.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/sql/maxdb/maxdb.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -0,0 +1,130 @@
+# GNU Enterprise Common - MaxDB/SAP-DB DB driver - Connection
+#
+# Copyright 2001-2005 Free Software Foundation
+#
+# This file is part of GNU Enterprise
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+
+__all__ = ['Connection']
+
+from gnue.common.datasources.drivers import DBSIG2
+from gnue.common.datasources.drivers.sql.maxdb import Behavior
+
+
+# =============================================================================
+# Test if plugin is functional
+# =============================================================================
+
+def __initplugin__ ():
+ from gnue.common.datasources import GConnections
+ try:
+ import sapdb.dbapi
+
+ except ImportError:
+ raise GConnections.DependencyError, ('sapdb', None)
+
+
+# =============================================================================
+# Driver info
+# =============================================================================
+
+class DriverInfo:
+
+ name = "MySQL's MaxDB driver"
+
+ url = "http://www.mysql.com/products/maxdb/sapdbapi.html"
+
+ doc = """
+Description
+-----------
+Python driver for MaxDB/SAPDB version 7.x+.
+
+Support
+-------
+Supported Platforms:
+
+ - Linux/BSD
+ - MS Windows 98/NT/2000/XP
+
+Connection Properties
+---------------------
+* host -- This is the MaxDB host for your connection (optional)
+* dbname -- This is the MaxDB database to use (required)
+* timeout -- Command timeout in seconds (optional)
+* isolation -- Isolation level (optional) (0, 1 [default], 10, 15, 2, 20, 3,
30)
+* sqlmode -- INTERNAL (default) or ORACLE (optional)
+* sqlsubmode -- ODBC or empty (optional)
+
+Examples
+--------
+# This connection uses the SAP DB driver
+# We will be connecting to the SAP DB server on
+# "localhost" to a database called "TST".
+[sapdb]
+comment = XYZ Development Database
+provider = sapdb
+host=dbs.mydomain.com
+dbname = TST
+timeout = 900
+
+Notes
+-----
+1. The driver is fully functional
+"""
+
+
+# =============================================================================
+# MaxDB/SAP-DB Connection class
+# =============================================================================
+
+class Connection (DBSIG2.Connection):
+ """
+ Connection class for MaxDB and SAP-DB databases.
+ """
+
+ _drivername = 'sapdb.dbapi'
+ _behavior = Behavior.Behavior
+
+ _named_as_sequence = True
+
+
+ # ---------------------------------------------------------------------------
+ # Get connection parameters
+ # ---------------------------------------------------------------------------
+
+ def _getConnectParams (self, connectData):
+
+ # mandatory parameters
+ # FIXME: would it be possible to use kwargs for these parameters, too?
+ params = [(connectData ['_username']).upper(),
+ connectData ['_password'],
+ connectData ['dbname'],
+ connectData.get ('host', '')]
+
+ # keyword arguments
+ kwargs = {}
+
+ for gnueName, sapdbName in [('sqlmode' , 'sqlmode'),
+ ('timeout' , 'timeout'),
+ ('isolation' , 'isolation'),
+ ('sqlsubmode', 'component')]:
+ if connectData.has_key (gnueName):
+ kwargs [sapdbName] = connectData [gnueName]
+
+ return (params, kwargs)
Copied: trunk/gnue-common/src/datasources/drivers/sql/msado/Behavior.py (from
rev 7618, trunk/gnue-common/src/datasources/drivers/adodbapi/Behavior.py)
Added: trunk/gnue-common/src/datasources/drivers/sql/msado/__init__.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/sql/msado/__init__.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/sql/msado/__init__.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -0,0 +1,38 @@
+# GNU Enterprise Common Library - MS-ADO DB Driver
+#
+# Copyright 2000-2005 Free Software Foundation
+#
+# This file is part of GNU Enterprise.
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id: csvfile.py 7615 2005-06-17 15:24:00Z reinhard $
+
+"""
+Database driver plugin for MS-ADO backends.
+"""
+
+# =============================================================================
+# Driver info
+# =============================================================================
+
+class DriverInfo:
+ name = "MS ADO (MS SQL-Server/MS Access)"
+ url = ""
+ description = """
+The Microsoft ADO API allows access MS SQL-Server and MS Access databases.
+"""
+ isfree = False
Copied: trunk/gnue-common/src/datasources/drivers/sql/msado/adodbapi.py (from
rev 7618,
trunk/gnue-common/src/datasources/drivers/adodbapi/adodbapi/Connection.py)
===================================================================
--- trunk/gnue-common/src/datasources/drivers/adodbapi/adodbapi/Connection.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/sql/msado/adodbapi.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -0,0 +1,159 @@
+# GNU Enterprise Common Library - ADO DB Driver
+#
+# Copyright 2001-2005 Free Software Foundation
+#
+# This file is part of GNU Enterprise
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+
+__all__ = ['Connection']
+
+import string
+
+from gnue.common.datasources.drivers import DBSIG2
+from gnue.common.datasources.drivers.sql.msado import Behavior
+
+
+# =============================================================================
+# Test if plugin is functional
+# =============================================================================
+
+def __initplugin__ ():
+ from gnue.common.datasources import GConnections
+ try:
+ import adodbapi
+ except ImportError:
+ raise GConnections.DependencyError, ('adodbapi', None)
+ try:
+ import win32com
+ except ImportError:
+ raise GConnections.DependencyError, ('win32com', None)
+
+
+# =============================================================================
+# Driver info
+# =============================================================================
+
+class DriverInfo:
+
+ name = "adodbapi"
+
+ url = "http://sourceforge.net/projects/adodbapi"
+
+ doc = """
+Description
+-----------
+A Python DB-API 2.0 module that makes it easy to use Microsoft ADO
+for connecting with databases and other data sources.
+
+Prerequisites:
+
+ * Mark Hammond's win32all python for windows extensions.
+
+
+Support
+-------
+Supported Platforms:
+
+ - MS Windows 98/NT/2000/XP (Installer available)
+
+
+Connection Properties
+----------------------
+* oledb_provider (required)
+* data_source (required)
+* initial_catalog (optional for SQL Server)
+* network_library (optional for SQL Server)
+* data_provider (optional for SQL Server)
+
+You can find more connection strings here:
+ http://www.able-consulting.com/MDAC/ADO/Connection/OLEDB_Providers.htm
+
+Examples
+--------
+ [access]
+ comment = MS Access database
+ provider = adodbapi
+ oledb_provider = Microsoft.Jet.OLEDB.4.0
+ data_source = C:\mydb.mdb
+
+ [sqlserver]
+ comment = MS SQL Server database
+ provider = adodbapi
+ oledb_provider = sqloledb
+ data_source = myServerName
+ initial_catalog = myDatabaseName
+
+Notes
+-----
+1. This driver is only usable under MS Windows.
+
+2. This driver does not implement schema creation. Index introspection is not
+ supported by this driver
+
+3. MS SQL Server has been tested successfully. MS Access backends need some
+ more testing
+
+4. Other than that, the driver is fully functional with no known serious
+ problems.
+"""
+
+
+# =============================================================================
+# ADO Connection class
+# =============================================================================
+
+class Connection (DBSIG2.Connection):
+ """
+ Connection class for ADO databases.
+ """
+
+ _drivername = 'adodbapi'
+
+ _broken_rowcount = True
+
+ defaultBehavior = Behavior.Behavior
+
+
+ # ---------------------------------------------------------------------------
+ # Build up parameters for connect method
+ # ---------------------------------------------------------------------------
+
+ def _getConnectParams (self, connectData):
+
+ import adodbapi
+
+ adodbapi.defaultIsolationLevel = adodbapi.adXactSerializable
+
+ # mandatory parameters
+ params = {'Provider' : connectData ['oledb_provider'],
+ 'Data Source': connectData ['data_source'],
+ 'User Id' : connectData ['_username'],
+ 'Password' : connectData ['_password']}
+
+ # optional parameters
+ for gnueName, oledbName in [('initial_catalog', 'Initial Catalog'),
+ ('network_library', 'Network Library'),
+ ('data_provider' , 'Data Provider' )]:
+ if connectData.has_key (gnueName):
+ params [oledbName] = connectData [gnueName]
+
+ p = ["%s=%s" % (k, v) for (k, v) in params.items ()]
+ connectstring = string.join (p, ';')
+
+ return ([connectstring], {})
Copied: trunk/gnue-common/src/datasources/drivers/sql/mysql/Behavior.py (from
rev 7618, trunk/gnue-common/src/datasources/drivers/mysql/Behavior.py)
Copied: trunk/gnue-common/src/datasources/drivers/sql/mysql/__init__.py (from
rev 7618, trunk/gnue-common/src/datasources/drivers/mysql/__init__.py)
===================================================================
--- trunk/gnue-common/src/datasources/drivers/mysql/__init__.py 2005-06-18
11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/sql/mysql/__init__.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -0,0 +1,45 @@
+# GNU Enterprise Common Library - MySQL DB Driver
+#
+# Copyright 2000-2005 Free Software Foundation
+#
+# This file is part of GNU Enterprise.
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+
+"""
+Database driver plugin for MySQL backends.
+"""
+
+# =============================================================================
+# Driver info
+# =============================================================================
+
+class DriverInfo:
+ name = "MySQL (4.x+)"
+ url = "http://www.mysql.org/"
+ description = """
+MySQL is a fast database that runs on numerous platforms. It is one of the
+most popular free databases available.
+
+Given the transactional nature of GNUe, we recommend using MySQL 4.x+ with
+transaction support compiled in.
+
+Not all features of GNUe are usable under MySQL, such as auto-populating fields
+with serials/sequences and query-by-detail.
+"""
+ isfree = True
Copied: trunk/gnue-common/src/datasources/drivers/sql/mysql/mysqldb.py (from
rev 7618, trunk/gnue-common/src/datasources/drivers/mysql/mysql/Connection.py)
===================================================================
--- trunk/gnue-common/src/datasources/drivers/mysql/mysql/Connection.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/sql/mysql/mysqldb.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -0,0 +1,151 @@
+# GNU Enterprise Common Library - MySQL DB Driver
+#
+# Copyright 2001-2005 Free Software Foundation
+#
+# This file is part of GNU Enterprise
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+
+__all__ = ['Connection']
+
+from gnue.common.datasources.drivers import DBSIG2
+from gnue.common.datasources.drivers.sql.mysql import Behavior
+
+
+# =============================================================================
+# Test if plugin is functional
+# =============================================================================
+
+def __initplugin__ ():
+ from gnue.common.datasources import GConnections
+ try:
+ import MySQLdb
+ except ImportError:
+ raise GConnections.DependencyError ('mysql-python',
+ 'http://sourceforge.net/projects/mysql-python')
+
+
+# =============================================================================
+# Driver info
+# =============================================================================
+
+class DriverInfo:
+
+ name = "MySQLdb"
+
+ url = "http://sourceforge.net/projects/mysql-python"
+
+ doc = """
+Description
+-----------
+Mysql-python, written by Andy Dustman, supports MySQL 3.22, 3.23, and
+4.x.
+
+Support
+-------
+Supported Platforms:
+
+ - Linux/BSD
+ - Solaris
+ - MS Windows 98/NT/2000/XP (Installer available)
+
+Connection Properties
+----------------------
+* host -- This is the host for your connection (required)
+* dbname -- This is the name of the database to use (required)
+
+Examples
+--------
+ [myconn]
+ provider=mysql # Use the MySQLdb adapter
+ host=localhost # The hostname/IP of the MySQL host
+ dbname=mydb # The name of the MySQL database
+
+Notes
+-----
+1. Transactions are supported if MySQL is compiled with proper
+ transactional support (3.x series does NOT do this by default!).
+
+2. Windows installer available at http://www.cs.fhm.edu/~ifw00065/.
+
+3. Other than that, the driver is fully functional with no known serious
+ problems.
+"""
+
+
+# =============================================================================
+# MySQL Connection class
+# =============================================================================
+
+class Connection (DBSIG2.Connection):
+ """
+ Connection class for Interbase databases.
+ """
+
+ _drivername = 'MySQLdb'
+ _behavior = Behavior.Behavior
+
+ _boolean_true = 1
+ _boolean_false = 0
+
+
+ # ---------------------------------------------------------------------------
+ # Get connection parameters
+ # ---------------------------------------------------------------------------
+
+ def _getConnectParams (self, connectData):
+
+ # mandatory parameters
+ kwargs = {'db' : connectData ['dbname'],
+ 'user' : connectData ['_username'],
+ 'passwd': connectData ['_password'] or ''}
+
+ # optional parameters
+ for gnueName, ibName in [('host', 'host')]:
+ if connectData.has_key (gnueName):
+ kwargs [ibName] = connectData [gnueName]
+
+ return ([], kwargs)
+
+
+ # ---------------------------------------------------------------------------
+ # Start a new transaction
+ # ---------------------------------------------------------------------------
+
+ def _beginTransaction (self):
+ # only available if MySQL is compiled with transaction support
+ try:
+ self._native.begin ()
+ except:
+ pass
+
+
+ # ---------------------------------------------------------------------------
+ # Return the current date, according to database
+ # ---------------------------------------------------------------------------
+
+ def getTimeStamp (self):
+ return self.sql1 ("select current_timestamp")
+
+
+ # ---------------------------------------------------------------------------
+ # Return a sequence number from sequence 'name'
+ # ---------------------------------------------------------------------------
+
+ # def getSequence (self, name):
+ # (not available in MySQL)
Copied: trunk/gnue-common/src/datasources/drivers/sql/oracle/Base.py (from rev
7618, trunk/gnue-common/src/datasources/drivers/oracle/Base/Connection.py)
===================================================================
--- trunk/gnue-common/src/datasources/drivers/oracle/Base/Connection.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/sql/oracle/Base.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -0,0 +1,89 @@
+# GNU Enterprise Common Library - Generic Oracle DB driver
+#
+# Copyright 2001-2005 Free Software Foundation
+#
+# This file is part of GNU Enterprise
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+
+__all__ = ['Connection']
+
+__noplugin__ = True
+
+import os
+from gnue.common.datasources.drivers import DBSIG2
+from gnue.common.datasources.drivers.sql.oracle import Behavior
+
+
+# =============================================================================
+# Generic Oracle Connection class
+# =============================================================================
+
+class Connection (DBSIG2.Connection):
+ """
+ Generic Connection class for Oracle databases.
+ """
+
+ # TODO: Test if it would work with the default (True/False), too
+ _boolean_false = 0
+ _boolean_true = 1
+
+ _behavior = Behavior.Behavior
+
+
+ # ---------------------------------------------------------------------------
+ # Constructor
+ # ---------------------------------------------------------------------------
+
+ def __init__ (self, connections, name, parameters):
+
+ DBSIG2.Connection.__init__ (self, connections, name, parameters)
+
+ if parameters.has_key ('oracle_home'):
+ os.environ ['ORACLE_HOME'] = parameters ['oracle_home']
+
+
+ # ---------------------------------------------------------------------------
+ # Get connection parameters
+ # ---------------------------------------------------------------------------
+
+ def _getConnectParams (self, connectData):
+
+ connectstring = "%s/address@hidden" % (connectData ['_username'],
+ connectData ['_password'],
+ connectData ['service'])
+
+ return ([connectstring], {})
+
+
+ # ---------------------------------------------------------------------------
+ # Return the current date, according to database
+ # ---------------------------------------------------------------------------
+
+ def getTimeStamp (self):
+
+ return self.sql1 ("select sysdate from dual")
+
+
+ # ---------------------------------------------------------------------------
+ # Return a sequence number from sequence 'name'
+ # ---------------------------------------------------------------------------
+
+ def getSequence (self, name):
+
+ return self.sql1 ("select %s.nextval from dual" % name)
Copied: trunk/gnue-common/src/datasources/drivers/sql/oracle/Behavior.py (from
rev 7618, trunk/gnue-common/src/datasources/drivers/oracle/Behavior.py)
Copied: trunk/gnue-common/src/datasources/drivers/sql/oracle/__init__.py (from
rev 7618, trunk/gnue-common/src/datasources/drivers/oracle/__init__.py)
===================================================================
--- trunk/gnue-common/src/datasources/drivers/oracle/__init__.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/sql/oracle/__init__.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -0,0 +1,38 @@
+# GNU Enterprise Common Library - Oracle DB Drivers
+#
+# Copyright 2000-2005 Free Software Foundation
+#
+# This file is part of GNU Enterprise.
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+
+"""
+Database driver plugins for Oracle backends.
+"""
+
+# =============================================================================
+# Driver info
+# =============================================================================
+
+class DriverInfo:
+ name = "Oracle (7.3, 8i+)"
+ url = ""
+ description = """
+Oracle is a popular commercial relational database system.
+"""
+ isfree = False
Copied: trunk/gnue-common/src/datasources/drivers/sql/oracle/cxoracle.py (from
rev 7618, trunk/gnue-common/src/datasources/drivers/oracle/cxoracle/Driver.py)
===================================================================
--- trunk/gnue-common/src/datasources/drivers/oracle/cxoracle/Driver.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/sql/oracle/cxoracle.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -0,0 +1,98 @@
+# GNU Enterprise Common Library - Oracle DB driver using cxoracle
+#
+# Copyright 2001-2005 Free Software Foundation
+#
+# This file is part of GNU Enterprise
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+
+__all__ = ('Connection')
+
+from gnue.common.datasources.drivers.sql.oracle import Base
+
+
+# =============================================================================
+# Test if plugin is functional
+# =============================================================================
+
+def __initplugin__ ():
+ from gnue.common.datasources import GConnections
+ try:
+ import cx_Oracle
+ except ImportError:
+ raise GConnections.DependencyError, ('cx_Oracle', None)
+
+
+# =============================================================================
+# Driver info
+# =============================================================================
+
+class DriverInfo:
+
+ name = "cx_Oracle SQLNet Driver"
+
+ url = "http://www.computronix.com/utilities.shtml"
+
+ doc = """
+Description
+-----------
+An Oracle driver from Computronix. Works with Oracle 7.3, 8.x, and 9i via
+Oracle's SQL-Net OCI interface.
+
+Support
+-------
+Supported Platforms:
+
+ - Linux/BSD
+ - Solaris
+ - MS Windows 98/NT/2000/XP (Installer available)
+
+
+Connection Properties
+----------------------
+* service -- This is the Oracle TNS connection name
+
+Examples
+--------
+[myconn]
+provider=cxoracle # Use the CX Oracle adapter
+service=mytnsname # The TNS connection string of the database
+
+Notes
+-----
+1. Requires Oracle Client Libraries.
+
+2. Does not recognize the TWO_TASK environment setting.
+
+3. Creation of new databases with "gnue-schema --createdb" does not
+ work with this driver. Index introspection is not supported.
+
+4. Other than that, the driver is fully functional with no known serious
+ problems.
+"""
+
+
+# =============================================================================
+# Oracle Connection class using cxoracle
+# =============================================================================
+
+class Connection (Base.Connection):
+ """
+ Connection class for Oracle databases using the cxoracle DBSIG2 driver.
+ """
+ _drivername = 'cx_Oracle'
Copied: trunk/gnue-common/src/datasources/drivers/sql/oracle/dcoracle.py (from
rev 7618, trunk/gnue-common/src/datasources/drivers/oracle/dcoracle/Driver.py)
===================================================================
--- trunk/gnue-common/src/datasources/drivers/oracle/dcoracle/Driver.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/sql/oracle/dcoracle.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -0,0 +1,101 @@
+# GNU Enterprise Common Library - Oracle DB driver using cxoracle
+#
+# Copyright 2001-2005 Free Software Foundation
+#
+# This file is part of GNU Enterprise
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+
+__all__ = ('Connection')
+
+from gnue.common.datasources.drivers.sql.oracle import Base
+
+
+# =============================================================================
+# Test if plugin is functional
+# =============================================================================
+
+def __initplugin__ ():
+ from gnue.common.datasources import GConnections
+ try:
+ import DCOracle2
+ except ImportError:
+ raise GConnections.DependencyError ('DCOracle2', None)
+
+
+# =============================================================================
+# Driver info
+# =============================================================================
+
+class DriverInfo:
+
+ name = "DCOracle2 OCI Driver"
+
+ url = "http://www.zope.org/Members/matt/dco2/"
+
+ doc = """
+Description
+-----------
+An Oracle driver from Digital Creations (Zope). Works with Oracle
+7.3, 8.x, 9i via Oracle's SQL-Net OCI interface.
+
+The "Oracle Database Bindings for Python" are packaged with the
+"Zope Oracle Database Adapter". GNUe does not use the Zope
+Adapter, so you can safely ignore any installation instructions
+referring to Zope.
+
+Support
+-------
+Supported Platforms:
+
+ - Linux/BSD
+ - Solaris
+ - MS Windows 98/NT/2000/XP (Installer available)
+
+Connection Properties
+----------------------
+* service -- This is the Oracle TNS connection name
+
+Examples
+--------
+provider=oracle # Use the DCOracle2 adapter
+service=mytnsname # The TNS connection string of the database
+
+Notes
+-----
+1. Requires Oracle Client Libraries.
+
+2. Does not recognize the TWO_TASK environment setting.
+
+3. Creation of new databases with "gnue-schema --createdb" does not
+ work with this driver. Index introspection is not supported
+
+4. Other than that, the driver is fully functional with no known serious
+ problems.
+"""
+
+
+# =============================================================================
+# Oracle Connection class using dcoracle
+# =============================================================================
+
+class Connection (Base.Connection):
+ """
+ Connection class for Oracle databases using the cxoracle DBSIG2 driver.
+ """
+ _drivername = 'DCOracle2'
Copied: trunk/gnue-common/src/datasources/drivers/sql/postgres/Base.py (from
rev 7618,
trunk/gnue-common/src/datasources/drivers/postgresql/Base/Connection.py)
===================================================================
--- trunk/gnue-common/src/datasources/drivers/postgresql/Base/Connection.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/sql/postgres/Base.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -0,0 +1,146 @@
+# GNU Enterprise Common Library - Generic Postgres DB driver
+#
+# Copyright 2001-2005 Free Software Foundation
+#
+# This file is part of GNU Enterprise
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+
+__all__ = ['Connection']
+
+__noplugin__ = True
+
+from gnue.common.datasources.drivers import DBSIG2
+from gnue.common.datasources.drivers.sql.postgres import Behavior
+
+
+# =============================================================================
+# Generic PostgreSQL Connection class
+# =============================================================================
+
+class Connection (DBSIG2.Connection):
+ """
+ Generic Connection class for PostgreSQL databases.
+ """
+
+ _rowidField = 'oid'
+ _behavior = Behavior.Behavior
+
+
+ # ---------------------------------------------------------------------------
+ # Constructor
+ # ---------------------------------------------------------------------------
+
+ def __init__ (self, connections, name, parameters):
+
+ DBSIG2.Connection.__init__ (self, connections, name, parameters)
+
+ # Find out encoding for Postgres
+ if pg_encTable.has_key (self._encoding):
+ self._pg_encoding = pg_encTable [self._encoding]
+ else:
+ self._pg_encoding = ''
+ gDebug (1, "Encoding '%s' is not supported by postgresql dbdriver. "
+ "Using default encoding." % self._encoding)
+
+
+ # ---------------------------------------------------------------------------
+ # Get connection parameters
+ # ---------------------------------------------------------------------------
+
+ def _getConnectParams (self, connectData):
+
+ # mandatory parameters
+ kwargs = {'database': connectData ['dbname'],
+ 'user' : connectData ['_username'],
+ 'password': connectData ['_password']}
+
+ # optional parameters
+ for gnueName, pgName in [('host', 'host'),
+ ('port', 'port')]:
+ if connectData.has_key (gnueName):
+ kwargs [pgName] = connectData [gnueName]
+
+ return ([], kwargs)
+
+
+ # ---------------------------------------------------------------------------
+ # Done at the start of each transaction
+ # ---------------------------------------------------------------------------
+
+ def _beginTransaction (self):
+
+ # Must set CLIENT_ENCODING per transaction as it is reset on COMMIT or
+ # ROLLBACK.
+
+ if self._pg_encoding not in ['', 'DEFAULT']:
+ self.sql0 ("SET CLIENT_ENCODING TO '%s'" % self._pg_encoding)
+
+
+ # ---------------------------------------------------------------------------
+ # Return the current date, according to database
+ # ---------------------------------------------------------------------------
+
+ def getTimeStamp (self):
+
+ return self.sql1 ("select current_timestamp")
+
+
+ # ---------------------------------------------------------------------------
+ # Return a sequence number from sequence 'name'
+ # ---------------------------------------------------------------------------
+
+ def getSequence (self, name):
+
+ return self.sql1 ("select nextval('%s')" % name)
+
+
+# =============================================================================
+# Encoding-Table
+# =============================================================================
+
+pg_encTable = {
+ 'ascii' : 'SQL_ASCII', # ASCII
+ '' : 'EUC_JP', # Japanese EUC
+ '' : 'EUC_CN', # Chinese EUC
+ '' : 'EUC_KR', # Korean EUC
+ '' : 'JOHAB', # Korean EUC (Hangle base)
+ '' : 'EUC_TW', # Taiwan EUC
+ 'utf-8' : 'UNICODE', # Unicode (UTF-8)
+ '' : 'MULE_INTERNAL', # Mule internal code
+ 'iso8859-1' : 'LATIN1', # ISO 8859-1 ECMA-94 Latin Alphabet No.1
+ 'iso8859-2' : 'LATIN2', # ISO 8859-2 ECMA-94 Latin Alphabet No.2
+ 'iso8859-3' : 'LATIN3', # ISO 8859-3 ECMA-94 Latin Alphabet No.3
+ 'iso8859-4' : 'LATIN4', # ISO 8859-4 ECMA-94 Latin Alphabet No.4
+ 'iso8859-9' : 'LATIN5', # ISO 8859-9 ECMA-128 Latin Alphabet No.5
+ 'iso8859-10': 'LATIN6', # ISO 8859-10 ECMA-144 Latin Alphabet No.6
+ 'iso8859-13': 'LATIN7', # ISO 8859-13 Latin Alphabet No.7
+ 'iso8859-14': 'LATIN8', # ISO 8859-14 Latin Alphabet No.8
+ 'iso8859-15': 'LATIN9', # ISO 8859-15 Latin Alphabet No.9
+ 'iso8859-16': 'LATIN10', # ISO 8859-16 ASRO SR 14111 Latin Alph. No.10
+ 'iso8859-5' : 'ISO-8859-5', # ECMA-113 Latin/Cyrillic
+ 'iso8859-6' : 'ISO-8859-6', # ECMA-114 Latin/Arabic
+ 'iso8859-7' : 'ISO-8859-7', # ECMA-118 Latin/Greek
+ 'iso8859-8' : 'ISO-8859-8', # ECMA-121 Latin/Hebrew
+ 'koi8-r' : 'KOI8', # KOI8-R(U)
+ 'cp1251' : 'WIN', # Windows CP1251
+ '' : 'ALT', # Windows CP866
+ '' : 'WIN1256', # Arabic Windows CP1256
+ '' : 'TCVN', # Vietnamese TCVN-5712 (Windows CP1258)
+ '' : 'WIN874', # Thai Windows CP874
+}
Copied: trunk/gnue-common/src/datasources/drivers/sql/postgres/Behavior.py
(from rev 7618,
trunk/gnue-common/src/datasources/drivers/postgresql/Behavior.py)
Copied: trunk/gnue-common/src/datasources/drivers/sql/postgres/__init__.py
(from rev 7618,
trunk/gnue-common/src/datasources/drivers/postgresql/__init__.py)
===================================================================
--- trunk/gnue-common/src/datasources/drivers/postgresql/__init__.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/sql/postgres/__init__.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -0,0 +1,52 @@
+# GNU Enterprise Common Library - PostgreSQL DB Driver
+#
+# Copyright 2000-2005 Free Software Foundation
+#
+# This file is part of GNU Enterprise.
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+
+"""
+Database driver plugin for PostgreSQL backends.
+"""
+
+# =============================================================================
+# Define aliases
+# =============================================================================
+
+__pluginalias__ = ['pgsql', 'postgresql']
+
+
+# =============================================================================
+# Driver info
+# =============================================================================
+
+class DriverInfo:
+ name = "PostgreSQL (7.x+)"
+ url = "http://www.postgresql.org/"
+ description = """
+PostgreSQL is an free object-relational database, which supports a large part
+of SQL-99. It is under continuous development and each release implements
+more of the SQL standard, to the extent that it is now probably more compliant
+than most commercial databases. It also supports some object-oriented
+features. PostgreSQL is a full-featured, multi-user RDBMS that scales well
+from a few users to an entire organization.
+
+PostgreSQL is the primary database used by GNUe developers.
+"""
+ isfree = True
Copied: trunk/gnue-common/src/datasources/drivers/sql/postgres/psycopg.py (from
rev 7618,
trunk/gnue-common/src/datasources/drivers/postgresql/psycopg/Driver.py)
===================================================================
--- trunk/gnue-common/src/datasources/drivers/postgresql/psycopg/Driver.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/sql/postgres/psycopg.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -0,0 +1,96 @@
+# GNU Enterprise Common Library - Postgres DB driver using psycopg
+#
+# Copyright 2001-2005 Free Software Foundation
+#
+# This file is part of GNU Enterprise
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+
+__all__ = ('Connection')
+
+from gnue.common.datasources.drivers.sql.postgres import Base
+
+
+# =============================================================================
+# Test if plugin is functional
+# =============================================================================
+
+def __initplugin__ ():
+ from gnue.common.datasources import GConnections
+ try:
+ import psycopg
+ except:
+ raise GConnections.DependencyError, ('psycopg', None)
+
+
+# =============================================================================
+# Driver info
+# =============================================================================
+
+class DriverInfo:
+ name = "Psycopg"
+ url = "http://initd.org/software/initd/psycopg/"
+ doc = """
+Description
+-----------
+From the Psycopg website: "It was written from scratch with the aim of
+being very small and fast, and stable as a rock." Written by initd.org
+volunteers.
+
+Support
+-------
+Supported Platforms:
+
+ - Linux/BSD
+ - MS Windows 98/NT/2000/XP (Installer available)
+
+Connection Properties
+---------------------
+* dbname -- This is the database to use (required)
+* host -- This is the name of the database host, or, on Linux,
+ directory containing the network socket (optional)
+* port -- Port that PostgreSQL is running on (defaults to 5432) (optional)
+
+Examples
+--------
+ [myconn]
+ provider=psycopg # Use the psycopg adapter
+ host=localhost # The hostname/IP of the postgresql host
+ dbname=mydb # The name of the pg database
+
+Notes
+-----
+1. This is the driver of choice for PostgreSQL.
+
+2. Available in Debian as: "apt-get install python-psycopg".
+
+3. Windows installer available at:
http://stickpeople.com/projects/python/win-psycopg/.
+
+4. This driver is fully functional with no known serious problems.
+"""
+
+
+# =============================================================================
+# PostgreSQL Connection class using psycopg
+# =============================================================================
+
+class Connection (Base.Connection):
+ """
+ Connection class for PostgreSQL databases using the psycopg DBSIG2 driver.
+ """
+ _drivername = 'psycopg'
Copied: trunk/gnue-common/src/datasources/drivers/sql/postgres/pygresql.py
(from rev 7618,
trunk/gnue-common/src/datasources/drivers/postgresql/pygresql/Driver.py)
===================================================================
--- trunk/gnue-common/src/datasources/drivers/postgresql/pygresql/Driver.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/sql/postgres/pygresql.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -0,0 +1,89 @@
+# GNU Enterprise Common Library - Postgres DB driver using PyGreSQL
+#
+# Copyright 2001-2005 Free Software Foundation
+#
+# This file is part of GNU Enterprise
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+
+__all__ = ('Connection')
+
+from gnue.common.datasources.drivers.sql.postgres import Base
+
+
+# =============================================================================
+# Test if plugin is functional
+# =============================================================================
+
+def __initplugin__ ():
+ from gnue.common.datasources import GConnections
+ try:
+ import pgdb
+ except ImportError:
+ raise GConnections.DependencyError, ('pygresql', None)
+
+
+# =============================================================================
+# Driver info
+# =============================================================================
+
+class DriverInfo:
+ name = "PyGreSQL"
+ url = "http://druid.net/pygresql/"
+ doc = """
+Description
+-----------
+PyGreSQL is the PostgreSQL-Python driver available via PostgreSQL's CVS tree.
+It is compliant to Python's DB-API 2.0.
+
+Support
+-------
+Supported Platforms:
+
+ - Linux/BSD
+
+Connection Properties
+---------------------
+* dbname -- This is the database to use (required)
+* host -- This is the name of the database host, or, on Linux,
+ directory containing the network socket (optional)
+* port -- Port that PostgreSQL is running on (defaults to 5432) (optional)
+
+Examples
+--------
+ [myconn]
+ provider=pygresql # Use the pygresql adapter
+ host=localhost # The hostname/IP of the postgresql host
+ dbname=mydb # The name of the pg database
+
+Notes
+-----
+1. The developers of GNUe have had mixed results with the PygreSQL driver
+ and generally recommend one of the others.
+"""
+
+
+# =============================================================================
+# PostgreSQL Connection class using PyGreSQL
+# =============================================================================
+
+class Connection (Base.Connection):
+ """
+ Connection class for PostgreSQL databases using the PyGreSQL DBSIG2 driver.
+ """
+ _drivername = 'pgdb'
Copied: trunk/gnue-common/src/datasources/drivers/sql/postgres/pypgsql.py (from
rev 7618,
trunk/gnue-common/src/datasources/drivers/postgresql/pypgsql/Driver.py)
===================================================================
--- trunk/gnue-common/src/datasources/drivers/postgresql/pypgsql/Driver.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/sql/postgres/pypgsql.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -0,0 +1,98 @@
+# GNU Enterprise Common Library - Postgres DB driver using pyPgSQL
+#
+# Copyright 2001-2005 Free Software Foundation
+#
+# This file is part of GNU Enterprise
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+
+__all__ = ('Connection')
+
+from gnue.common.datasources.drivers.sql.postgres import Base
+
+
+# =============================================================================
+# Test if plugin is functional
+# =============================================================================
+
+def __initplugin__ ():
+ from gnue.common.datasources import GConnections
+ try:
+ from pyPgSQL import PgSQL
+ except:
+ raise GConnections.DependencyError, ('pyPgSQL', None)
+
+
+# =============================================================================
+# Driver info
+# =============================================================================
+
+class DriverInfo:
+ name = "pyPgSQL"
+ url = "http://pypgsql.sf.net/"
+ doc = """
+Description
+-----------
+Written by Billy Allie, pyPgSQL is a database interface for PostgreSQL 7.x.
+
+Support
+-------
+Supported Platforms:
+
+ - Linux/BSD
+ - MS Windows 98/NT/2000/XP (Installer available)
+
+Platforms Tested:
+
+ - GNU/Linux [Debian 2.x, 3.x, Slackware 8.0, RedHat ]
+ - Windows 98/2000/XP
+
+Connection Properties
+---------------------
+* dbname -- This is the database to use (required)
+* host -- This is the name of the database host, or, on Linux,
+ directory containing the network socket (optional)
+* port -- Port that PostgreSQL is running on (defaults to 5432) (optional)
+
+Examples
+--------
+ [myconn]
+ provider=pypgsql # Use the pypgsql adapter
+ host=localhost # The hostname/IP of the postgresql host
+ dbname=mydb # The name of the pg database
+
+Notes
+-----
+1. pyPgSQL is available in Debian as python-pgsql.
+
+2. This driver is fully functional with no known serious problems.
+"""
+
+
+# =============================================================================
+# PostgreSQL Connection class using pyPgSQL
+# =============================================================================
+
+class Connection (Base.Connection):
+ """
+ Connection class for PostgreSQL databases using the pyPgSQL DBSIG2 driver.
+ """
+ _drivername = 'pyPgSQL.PgSQL'
+ _rowidField = None # PyPgSQL doesn't support rowid's!!
+ _broken_fetchmany = True
+ _broken_rowcount = True
Copied: trunk/gnue-common/src/datasources/drivers/sql/sqlite/Behavior.py (from
rev 7618, trunk/gnue-common/src/datasources/drivers/sqlite/Behavior.py)
Copied: trunk/gnue-common/src/datasources/drivers/sql/sqlite/__init__.py (from
rev 7618, trunk/gnue-common/src/datasources/drivers/sqlite/__init__.py)
===================================================================
--- trunk/gnue-common/src/datasources/drivers/sqlite/__init__.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/sql/sqlite/__init__.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -0,0 +1,43 @@
+# GNU Enterprise Common Library - SQLite DB Driver
+#
+# Copyright 2000-2005 Free Software Foundation
+#
+# This file is part of GNU Enterprise.
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+
+"""
+Database driver plugin for SQLite backends.
+"""
+
+# =============================================================================
+# Driver info
+# =============================================================================
+
+class DriverInfo:
+ name = "SQLite Embedded Database"
+ url = "http://www.sqlite.org/"
+ description = """
+SQLite is a C library that implements an embeddable SQL database engine.
+Programs that link with the SQLite library can have SQL database access
+without running a separate RDBMS process.
+
+SQLite is a great database to use with GNUe for single-user installations
+where a self-contained, distributable package is desired.
+"""
+ isfree = True
Copied: trunk/gnue-common/src/datasources/drivers/sql/sqlite/pysqlite.py (from
rev 7618, trunk/gnue-common/src/datasources/drivers/sqlite/sqlite/Connection.py)
===================================================================
--- trunk/gnue-common/src/datasources/drivers/sqlite/sqlite/Connection.py
2005-06-18 11:24:31 UTC (rev 7618)
+++ trunk/gnue-common/src/datasources/drivers/sql/sqlite/pysqlite.py
2005-06-20 09:40:30 UTC (rev 7619)
@@ -0,0 +1,162 @@
+# GNU Enterprise Common Library - SQLite DB Driver
+#
+# Copyright 2001-2005 Free Software Foundation
+#
+# This file is part of GNU Enterprise
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+
+__all__ = ['Connection']
+
+from gnue.common.datasources.drivers import DBSIG2
+from gnue.common.datasources.drivers.sql.sqlite import Behavior
+
+
+# =============================================================================
+# Test if plugin is functional
+# =============================================================================
+
+def __initplugin__ ():
+ from gnue.common.datasources import GConnections
+ try:
+ import sqlite
+
+ # This is a workaround for a bug in PySQLite. All the following mebers are
+ # not imported from main.py in __init__.py
+ if not hasattr (sqlite, 'Timestamp') and sqlite.main.have_datetime:
+ sqlite.Date = sqlite.main.Date
+ sqlite.Time = sqlite.main.Time
+ sqlite.Timestamp = sqlite.main.Timestamp
+ sqlite.DateFromTicks = sqlite.main.DateFromTicks
+ sqlite.TimeFromTicks = sqlite.main.TimeFromTicks
+ sqlite.TimestampFromTicks = sqlite.main.TimestampFromTicks
+
+ sqlite.DateTimeType = sqlite.main.DateTimeType
+ sqlite.DateTimeDeltaType = sqlite.main.DateTimeDeltaType
+
+ except ImportError:
+ raise GConnections.DependencyError, ('SQLitedbapi', None)
+
+
+# =============================================================================
+# Driver info
+# =============================================================================
+
+class DriverInfo:
+
+ name = "PySQLite Driver"
+
+ url = "http://pysqlite.sourceforge.net/"
+
+ doc = """
+Description
+-----------
+PySQLite is a Python extension for SQLite that conforms to the Python
+Database API Specification 2.0. The source is released under the
+Python license.
+
+Support
+-------
+Supported Platforms:
+
+ - Linux/BSD
+ - Solaris
+ - MS Windows 98/NT/2000/XP
+
+Connection Properties
+---------------------
+* dbname -- This is the file name of the sqlite database (required)
+
+Examples
+--------
+[myconn]
+provider=sqlite # Use the SQLite adapter
+dbname=/usr/db/testdb # The filename for the SQLite database
+
+Notes
+-----
+1. The database engine stores all data in string format. Many
+ SQL statements won't work. Comparison of date types won't work
+ correctly, etc.
+
+2. Other than that, this driver is fully functional without any serious
+ known problems.
+"""
+
+
+# =============================================================================
+# SQLite Connection class
+# =============================================================================
+
+class Connection (DBSIG2.Connection):
+
+ _drivername = 'sqlite'
+ _behavior = Behavior.Behavior
+
+ # SQLite doesn't like boolean type in SQL parameters
+ _boolean_true = 1
+ _boolean_false = 0
+
+
+ # ---------------------------------------------------------------------------
+ # Constructor
+ # ---------------------------------------------------------------------------
+
+ def __init__ (self, connections, name, parameters):
+
+ DBSIG2.Connection.__init__ (self, connections, name, parameters)
+ # FIXME: what was the problem with transactions? Comment should go here.
+ self.__noTransactions = parameters.get ('appserver', False)
+
+
+ # ---------------------------------------------------------------------------
+ # Return a sequence of required login fields
+ # ---------------------------------------------------------------------------
+
+ def _getLoginFields (self):
+ """
+ This function returns an empty sequence since SQLite doesn't use any user
+ authentication.
+ """
+ return []
+
+
+ # ---------------------------------------------------------------------------
+ # Get connection parameters
+ # ---------------------------------------------------------------------------
+
+ def _getConnectParams (self, connectData):
+
+ # mandatory parameters
+ kwargs = {'db' : connectData ['dbname'],
+ 'encoding' : self._encoding,
+ 'autocommit': self.__noTransactions}
+
+ return ([], kwargs)
+
+
+ # ---------------------------------------------------------------------------
+ # Commit a pending transactiona pending transaction
+ # ---------------------------------------------------------------------------
+
+ def _commit (self):
+ """
+ This function performs a commit depending on the current transaction-flag.
+ """
+ if not self.__noTransactions:
+ DBSIG2.Connection._commit (self)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r7619 - in trunk/gnue-common/src/datasources/drivers: . file postgresql postgresql/Base postgresql/psycopg postgresql/pygresql postgresql/pypgsql sql sql/interbase sql/maxdb sql/msado sql/mysql sql/oracle sql/postgres sql/sqlite,
reinhard <=