2
# This file is part of GNU Enterprise.
4
# GNU Enterprise is free software; you can redistribute it
5
# and/or modify it under the terms of the GNU General Public
6
# License as published by the Free Software Foundation; either
7
# version 2, or (at your option) any later version.
9
# GNU Enterprise is distributed in the hope that it will be
10
# useful, but WITHOUT ANY WARRANTY; without even the implied
11
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12
# PURPOSE. See the GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public
15
# License along with program; see the file COPYING. If not,
16
# write to the Free Software Foundation, Inc., 59 Temple Place
17
# - Suite 330, Boston, MA 02111-1307, USA.
19
# Copyright 2000-2005 Free Software Foundation
22
# SQLRelay/DBdriver.py
25
# Driver to provide access to data via SQLRelay's Python Driver
26
# Requires SQLRelay + Python-DB Driver (http://www.firstworks.com/sqlrelay)
30
# Supported attributes (via connections.conf or <database> tag)
32
# host= This is the SQLRelay host for your connection (required)
33
# In the format hostname:port (or ipaddr:port)
36
__all__ = ['Connection']
39
#### IF YOU MODIFY ANY CONNECTION ####
40
#### ATTRIBUTES, PLEASE UPDATE info.py ####
44
from string import lower
46
from gnue.common.datasources import GDataObjects, GConditions, GConnections
47
from gnue.common.apps import GDebug
48
from gnue.common.datasources.drivers import DBSIG2
51
from SQLRelay import PySQLRDB as SIG2api
53
raise GConnections.DependencyError, ('SQLRelay', None)
56
from gnue.common.datasources.drivers.sqlrelay.Schema.Discovery.Introspection import Introspection
59
######################################################################
61
# GConnection object for PostgreSQL-based drivers
63
class Connection(DBSIG2.Connection):
66
defaultBehavior = Introspection
67
_DatabaseError = SIG2api.DatabaseError
68
supportedDataObjects = {
69
'object': DataObject_Object,
74
def connect(self, connectData={}):
75
GDebug.printMesg(9,"SQLRelay database driver initializing")
77
host = connectData['host']
79
port = int(connectData['port'])
84
self.native = SIG2api.connect( host, port, '', \
85
connectData['_username'], \
86
connectData['_password'], \
88
except self._DatabaseError, value:
89
raise GDataObjects.LoginError, value