sqlobject 3.13.1__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sqlobject/__init__.py +15 -0
- sqlobject/__version__.py +8 -0
- sqlobject/boundattributes.py +124 -0
- sqlobject/cache.py +376 -0
- sqlobject/classregistry.py +138 -0
- sqlobject/col.py +2187 -0
- sqlobject/compat.py +59 -0
- sqlobject/conftest.py +64 -0
- sqlobject/constraints.py +77 -0
- sqlobject/converters.py +278 -0
- sqlobject/dbconnection.py +1137 -0
- sqlobject/dberrors.py +54 -0
- sqlobject/declarative.py +211 -0
- sqlobject/events.py +365 -0
- sqlobject/firebird/__init__.py +8 -0
- sqlobject/firebird/firebirdconnection.py +463 -0
- sqlobject/include/__init__.py +1 -0
- sqlobject/include/hashcol.py +109 -0
- sqlobject/include/tests/__init__.py +1 -0
- sqlobject/include/tests/test_hashcol.py +84 -0
- sqlobject/index.py +189 -0
- sqlobject/inheritance/__init__.py +551 -0
- sqlobject/inheritance/iteration.py +106 -0
- sqlobject/inheritance/tests/__init__.py +1 -0
- sqlobject/inheritance/tests/test_aggregates.py +23 -0
- sqlobject/inheritance/tests/test_asdict.py +48 -0
- sqlobject/inheritance/tests/test_deep_inheritance.py +114 -0
- sqlobject/inheritance/tests/test_destroy_cascade.py +23 -0
- sqlobject/inheritance/tests/test_foreignKey.py +94 -0
- sqlobject/inheritance/tests/test_indexes.py +42 -0
- sqlobject/inheritance/tests/test_inheritance.py +164 -0
- sqlobject/inheritance/tests/test_inheritance_tree.py +50 -0
- sqlobject/joins.py +656 -0
- sqlobject/main.py +1880 -0
- sqlobject/manager/__init__.py +1 -0
- sqlobject/manager/command.py +1309 -0
- sqlobject/maxdb/__init__.py +8 -0
- sqlobject/maxdb/maxdbconnection.py +320 -0
- sqlobject/maxdb/readme.txt +27 -0
- sqlobject/mssql/__init__.py +8 -0
- sqlobject/mssql/mssqlconnection.py +417 -0
- sqlobject/mysql/__init__.py +8 -0
- sqlobject/mysql/mysqlconnection.py +562 -0
- sqlobject/postgres/__init__.py +8 -0
- sqlobject/postgres/pgconnection.py +619 -0
- sqlobject/sqlbuilder.py +1655 -0
- sqlobject/sqlite/__init__.py +8 -0
- sqlobject/sqlite/sqliteconnection.py +418 -0
- sqlobject/sresults.py +377 -0
- sqlobject/styles.py +174 -0
- sqlobject/sybase/__init__.py +8 -0
- sqlobject/sybase/sybaseconnection.py +183 -0
- sqlobject/tests/__init__.py +1 -0
- sqlobject/tests/dbtest.py +363 -0
- sqlobject/tests/test_ForeignKey.py +133 -0
- sqlobject/tests/test_ForeignKey_cascade.py +150 -0
- sqlobject/tests/test_NoneValuedResultItem.py +33 -0
- sqlobject/tests/test_SQLMultipleJoin.py +65 -0
- sqlobject/tests/test_SQLRelatedJoin.py +114 -0
- sqlobject/tests/test_SingleJoin.py +30 -0
- sqlobject/tests/test_aggregates.py +75 -0
- sqlobject/tests/test_aliases.py +49 -0
- sqlobject/tests/test_asdict.py +18 -0
- sqlobject/tests/test_auto.py +218 -0
- sqlobject/tests/test_basic.py +359 -0
- sqlobject/tests/test_blob.py +34 -0
- sqlobject/tests/test_boundattributes.py +67 -0
- sqlobject/tests/test_cache.py +57 -0
- sqlobject/tests/test_class_hash.py +22 -0
- sqlobject/tests/test_columns_order.py +18 -0
- sqlobject/tests/test_combining_joins.py +47 -0
- sqlobject/tests/test_comparison.py +24 -0
- sqlobject/tests/test_compat.py +10 -0
- sqlobject/tests/test_complex_sorting.py +77 -0
- sqlobject/tests/test_constraints.py +43 -0
- sqlobject/tests/test_converters.py +276 -0
- sqlobject/tests/test_create_drop.py +29 -0
- sqlobject/tests/test_csvexport.py +101 -0
- sqlobject/tests/test_csvimport.py +21 -0
- sqlobject/tests/test_cyclic_reference.py +55 -0
- sqlobject/tests/test_datetime.py +171 -0
- sqlobject/tests/test_dbconnection.py +17 -0
- sqlobject/tests/test_decimal.py +63 -0
- sqlobject/tests/test_declarative.py +83 -0
- sqlobject/tests/test_default_style.py +65 -0
- sqlobject/tests/test_delete.py +74 -0
- sqlobject/tests/test_distinct.py +36 -0
- sqlobject/tests/test_empty.py +22 -0
- sqlobject/tests/test_enum.py +75 -0
- sqlobject/tests/test_events.py +142 -0
- sqlobject/tests/test_exceptions.py +40 -0
- sqlobject/tests/test_expire.py +29 -0
- sqlobject/tests/test_groupBy.py +45 -0
- sqlobject/tests/test_identity.py +29 -0
- sqlobject/tests/test_indexes.py +100 -0
- sqlobject/tests/test_inheritance.py +35 -0
- sqlobject/tests/test_joins.py +160 -0
- sqlobject/tests/test_joins_conditional.py +143 -0
- sqlobject/tests/test_jsonbcol.py +53 -0
- sqlobject/tests/test_jsoncol.py +56 -0
- sqlobject/tests/test_lazy.py +165 -0
- sqlobject/tests/test_md5.py +13 -0
- sqlobject/tests/test_mysql.py +50 -0
- sqlobject/tests/test_new_joins.py +165 -0
- sqlobject/tests/test_parse_uri.py +147 -0
- sqlobject/tests/test_paste.py +92 -0
- sqlobject/tests/test_perConnection.py +20 -0
- sqlobject/tests/test_pickle.py +42 -0
- sqlobject/tests/test_picklecol.py +44 -0
- sqlobject/tests/test_postgres.py +82 -0
- sqlobject/tests/test_reparent_sqlmeta.py +33 -0
- sqlobject/tests/test_schema.py +30 -0
- sqlobject/tests/test_select.py +218 -0
- sqlobject/tests/test_select_through.py +63 -0
- sqlobject/tests/test_setters.py +23 -0
- sqlobject/tests/test_slice.py +59 -0
- sqlobject/tests/test_sorting.py +80 -0
- sqlobject/tests/test_sqlbuilder.py +134 -0
- sqlobject/tests/test_sqlbuilder_dbspecific.py +66 -0
- sqlobject/tests/test_sqlbuilder_importproxy.py +55 -0
- sqlobject/tests/test_sqlbuilder_joins_instances.py +90 -0
- sqlobject/tests/test_sqlite.py +160 -0
- sqlobject/tests/test_sqlmeta_idName.py +52 -0
- sqlobject/tests/test_sqlobject_admin.py +38 -0
- sqlobject/tests/test_string_id.py +79 -0
- sqlobject/tests/test_style.py +36 -0
- sqlobject/tests/test_subqueries.py +142 -0
- sqlobject/tests/test_transactions.py +122 -0
- sqlobject/tests/test_unicode.py +84 -0
- sqlobject/tests/test_uuidcol.py +40 -0
- sqlobject/tests/test_validation.py +125 -0
- sqlobject/tests/test_views.py +159 -0
- sqlobject/util/__init__.py +1 -0
- sqlobject/util/csvexport.py +210 -0
- sqlobject/util/csvimport.py +366 -0
- sqlobject/util/moduleloader.py +35 -0
- sqlobject/util/threadinglocal.py +6 -0
- sqlobject/versioning/__init__.py +120 -0
- sqlobject/versioning/test/__init__.py +0 -0
- sqlobject/versioning/test/test_version.py +183 -0
- sqlobject/views.py +151 -0
- sqlobject/wsgi_middleware.py +109 -0
- sqlobject-3.13.1.data/scripts/sqlobject-admin +36 -0
- sqlobject-3.13.1.data/scripts/sqlobject-convertOldURI +19 -0
- sqlobject-3.13.1.dist-info/METADATA +177 -0
- sqlobject-3.13.1.dist-info/RECORD +149 -0
- sqlobject-3.13.1.dist-info/WHEEL +6 -0
- sqlobject-3.13.1.dist-info/entry_points.txt +4 -0
- sqlobject-3.13.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Contributed by Edigram SAS, Paris France Tel:01 44 77 94 00
|
|
3
|
+
Ahmed MOHAMED ALI <ahmedmoali@yahoo.com> 27 April 2004
|
|
4
|
+
|
|
5
|
+
This program is distributed in the hope that it will be useful, but
|
|
6
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
7
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
8
|
+
General Public License for more details.
|
|
9
|
+
|
|
10
|
+
connection creation sample::
|
|
11
|
+
|
|
12
|
+
__connection__ = DBConnection.maxdbConnection(
|
|
13
|
+
host=hostname, database=dbname,
|
|
14
|
+
user=user_name, password=user_password, autoCommit=1, debug=1)
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
import os
|
|
18
|
+
from sqlobject.dbconnection import DBAPI
|
|
19
|
+
from sqlobject import col
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class maxdbException(Exception):
|
|
23
|
+
|
|
24
|
+
def __init__(self, value):
|
|
25
|
+
self.value = value
|
|
26
|
+
|
|
27
|
+
def __str__(self):
|
|
28
|
+
return repr(self.value)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class LowerBoundOfSliceIsNotSupported(maxdbException):
|
|
32
|
+
def __init__(self, value):
|
|
33
|
+
maxdbException.__init__(self, '')
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class IncorrectIDStyleError(maxdbException):
|
|
37
|
+
def __init__(self, value):
|
|
38
|
+
maxdbException.__init__(
|
|
39
|
+
self,
|
|
40
|
+
'This primary key name is not in the expected style, '
|
|
41
|
+
'please rename the column to %r or switch to another style'
|
|
42
|
+
% value)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class StyleMismatchError(maxdbException):
|
|
46
|
+
def __init__(self, value):
|
|
47
|
+
maxdbException.__init__(
|
|
48
|
+
self,
|
|
49
|
+
'The name %r is only permitted for primary key, change the '
|
|
50
|
+
'column name or switch to another style' % value)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class PrimaryKeyNotFounded(maxdbException):
|
|
54
|
+
def __init__(self, value):
|
|
55
|
+
maxdbException.__init__(
|
|
56
|
+
self,
|
|
57
|
+
"No primary key was defined on table %r" % value)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
SAPDBMAX_ID_LENGTH = 32
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class MaxdbConnection(DBAPI):
|
|
64
|
+
|
|
65
|
+
supportTransactions = True
|
|
66
|
+
dbName = 'maxdb'
|
|
67
|
+
schemes = [dbName]
|
|
68
|
+
|
|
69
|
+
def __init__(self, host='', port=None, user=None, password=None,
|
|
70
|
+
database=None, autoCommit=1, sqlmode='internal',
|
|
71
|
+
isolation=None, timeout=None, **kw):
|
|
72
|
+
from sapdb import dbapi
|
|
73
|
+
self.module = dbapi
|
|
74
|
+
self.host = host
|
|
75
|
+
self.port = port
|
|
76
|
+
self.user = user
|
|
77
|
+
self.password = password
|
|
78
|
+
self.db = database
|
|
79
|
+
self.autoCommit = autoCommit
|
|
80
|
+
self.sqlmode = sqlmode
|
|
81
|
+
self.isolation = isolation
|
|
82
|
+
self.timeout = timeout
|
|
83
|
+
|
|
84
|
+
DBAPI.__init__(self, **kw)
|
|
85
|
+
|
|
86
|
+
@classmethod
|
|
87
|
+
def _connectionFromParams(cls, auth, password, host, port, path, args):
|
|
88
|
+
path = path.replace('/', os.path.sep)
|
|
89
|
+
return cls(host, port, user=auth, password=password, database=path,
|
|
90
|
+
**args)
|
|
91
|
+
|
|
92
|
+
def _getConfigParams(self, sqlmode, auto):
|
|
93
|
+
autocommit = 'off'
|
|
94
|
+
if auto:
|
|
95
|
+
autocommit = 'on'
|
|
96
|
+
opt = {}
|
|
97
|
+
opt["autocommit"] = autocommit
|
|
98
|
+
opt["sqlmode"] = sqlmode
|
|
99
|
+
if self.isolation:
|
|
100
|
+
opt["isolation"] = self.isolation
|
|
101
|
+
if self.timeout:
|
|
102
|
+
opt["timeout"] = self.timeout
|
|
103
|
+
return opt
|
|
104
|
+
|
|
105
|
+
def _setAutoCommit(self, conn, auto):
|
|
106
|
+
conn.close()
|
|
107
|
+
conn.__init__(self.user, self.password, self.db, self.host,
|
|
108
|
+
**self._getConfigParams(self.sqlmode, auto))
|
|
109
|
+
|
|
110
|
+
def createSequenceName(self, table):
|
|
111
|
+
"""
|
|
112
|
+
sequence name are builded with the concatenation of the table
|
|
113
|
+
name with '_SEQ' word we truncate the name of the
|
|
114
|
+
sequence_name because sapdb identifier cannot exceed 32
|
|
115
|
+
characters so that the name of the sequence does not exceed 32
|
|
116
|
+
characters
|
|
117
|
+
"""
|
|
118
|
+
return '%s_SEQ' % (table[:SAPDBMAX_ID_LENGTH - 4])
|
|
119
|
+
|
|
120
|
+
def makeConnection(self):
|
|
121
|
+
conn = self.module.Connection(
|
|
122
|
+
self.user, self.password, self.db, self.host,
|
|
123
|
+
**self._getConfigParams(self.sqlmode, self.autoCommit))
|
|
124
|
+
return conn
|
|
125
|
+
|
|
126
|
+
def _queryInsertID(self, conn, soInstance, id, names, values):
|
|
127
|
+
table = soInstance.sqlmeta.table
|
|
128
|
+
idName = soInstance.sqlmeta.idName
|
|
129
|
+
c = conn.cursor()
|
|
130
|
+
if id is None:
|
|
131
|
+
c.execute(
|
|
132
|
+
'SELECT %s.NEXTVAL FROM DUAL' % (
|
|
133
|
+
self.createSequenceName(table)))
|
|
134
|
+
id = c.fetchone()[0]
|
|
135
|
+
names = [idName] + names
|
|
136
|
+
values = [id] + values
|
|
137
|
+
q = self._insertSQL(table, names, values)
|
|
138
|
+
if self.debug:
|
|
139
|
+
self.printDebug(conn, q, 'QueryIns')
|
|
140
|
+
c.execute(q)
|
|
141
|
+
c.close()
|
|
142
|
+
if self.debugOutput:
|
|
143
|
+
self.printDebug(conn, id, 'QueryIns', 'result')
|
|
144
|
+
return id
|
|
145
|
+
|
|
146
|
+
@classmethod
|
|
147
|
+
def sqlAddLimit(cls, query, limit):
|
|
148
|
+
sql = query
|
|
149
|
+
sql = sql.replace("SELECT", "SELECT ROWNO, ")
|
|
150
|
+
if sql.find('WHERE') != -1:
|
|
151
|
+
sql = sql + ' AND ' + limit
|
|
152
|
+
else:
|
|
153
|
+
sql = sql + 'WHERE ' + limit
|
|
154
|
+
return sql
|
|
155
|
+
|
|
156
|
+
@classmethod
|
|
157
|
+
def _queryAddLimitOffset(cls, query, start, end):
|
|
158
|
+
if start:
|
|
159
|
+
raise LowerBoundOfSliceIsNotSupported
|
|
160
|
+
limit = ' ROWNO <= %d ' % (end)
|
|
161
|
+
return cls.sqlAddLimit(query, limit)
|
|
162
|
+
|
|
163
|
+
def createTable(self, soClass):
|
|
164
|
+
# We create the table in a transaction because the addition of the
|
|
165
|
+
# table and the sequence must be atomic.
|
|
166
|
+
|
|
167
|
+
# I tried to use the transaction class
|
|
168
|
+
# but I get a recursion limit error.
|
|
169
|
+
# t=self.transaction()
|
|
170
|
+
# t.query('CREATE TABLE %s (\n%s\n)' %
|
|
171
|
+
# (soClass.sqlmeta.table, self.createColumns(soClass)))
|
|
172
|
+
#
|
|
173
|
+
# t.query("CREATE SEQUENCE %s" %
|
|
174
|
+
# self.createSequenceName(soClass.sqlmeta.table))
|
|
175
|
+
# t.commit()
|
|
176
|
+
# so use transaction when the problem will be solved
|
|
177
|
+
self.query('CREATE TABLE %s (\n%s\n)' %
|
|
178
|
+
(soClass.sqlmeta.table, self.createColumns(soClass)))
|
|
179
|
+
self.query("CREATE SEQUENCE %s"
|
|
180
|
+
% self.createSequenceName(soClass.sqlmeta.table))
|
|
181
|
+
return []
|
|
182
|
+
|
|
183
|
+
def createReferenceConstraint(self, soClass, col):
|
|
184
|
+
return col.maxdbCreateReferenceConstraint()
|
|
185
|
+
|
|
186
|
+
def createColumn(self, soClass, col):
|
|
187
|
+
return col.maxdbCreateSQL()
|
|
188
|
+
|
|
189
|
+
def createIDColumn(self, soClass):
|
|
190
|
+
key_type = {int: "INT", str: "TEXT"}[soClass.sqlmeta.idType]
|
|
191
|
+
return '%s %s PRIMARY KEY' % (soClass.sqlmeta.idName, key_type)
|
|
192
|
+
|
|
193
|
+
def createIndexSQL(self, soClass, index):
|
|
194
|
+
return index.maxdbCreateIndexSQL(soClass)
|
|
195
|
+
|
|
196
|
+
def dropTable(self, tableName, cascade=False):
|
|
197
|
+
# We drop the table in a transaction because the removal of the
|
|
198
|
+
# table and the sequence must be atomic.
|
|
199
|
+
# I tried to use the transaction class
|
|
200
|
+
# but I get a recursion limit error.
|
|
201
|
+
# try:
|
|
202
|
+
# t=self.transaction()
|
|
203
|
+
# t.query("DROP TABLE %s" % tableName)
|
|
204
|
+
# t.query("DROP SEQUENCE %s" % self.createSequenceName(tableName))
|
|
205
|
+
# t.commit()
|
|
206
|
+
# except:
|
|
207
|
+
# t.rollback()
|
|
208
|
+
# so use transaction when the problem will be solved
|
|
209
|
+
self.query("DROP TABLE %s" % tableName)
|
|
210
|
+
self.query("DROP SEQUENCE %s" % self.createSequenceName(tableName))
|
|
211
|
+
|
|
212
|
+
def joinSQLType(self, join):
|
|
213
|
+
return 'INT NOT NULL'
|
|
214
|
+
|
|
215
|
+
def tableExists(self, tableName):
|
|
216
|
+
for (table,) in self.queryAll(
|
|
217
|
+
"SELECT OBJECT_NAME FROM ALL_OBJECTS "
|
|
218
|
+
"WHERE OBJECT_TYPE='TABLE'"):
|
|
219
|
+
if table.lower() == tableName.lower():
|
|
220
|
+
return True
|
|
221
|
+
return False
|
|
222
|
+
|
|
223
|
+
def addColumn(self, tableName, column):
|
|
224
|
+
self.query('ALTER TABLE %s ADD %s' %
|
|
225
|
+
(tableName,
|
|
226
|
+
column.maxdbCreateSQL()))
|
|
227
|
+
|
|
228
|
+
def delColumn(self, sqlmeta, column):
|
|
229
|
+
self.query('ALTER TABLE %s DROP COLUMN %s' % (sqlmeta.table,
|
|
230
|
+
column.dbName))
|
|
231
|
+
|
|
232
|
+
GET_COLUMNS = """
|
|
233
|
+
SELECT COLUMN_NAME, NULLABLE, DATA_DEFAULT, DATA_TYPE,
|
|
234
|
+
DATA_LENGTH, DATA_SCALE
|
|
235
|
+
FROM USER_TAB_COLUMNS WHERE TABLE_NAME=UPPER('%s')"""
|
|
236
|
+
|
|
237
|
+
GET_PK_AND_FK = """
|
|
238
|
+
SELECT constraint_cols.column_name, constraints.constraint_type,
|
|
239
|
+
refname,reftablename
|
|
240
|
+
FROM user_cons_columns constraint_cols
|
|
241
|
+
INNER JOIN user_constraints constraints
|
|
242
|
+
ON constraint_cols.constraint_name = constraints.constraint_name
|
|
243
|
+
LEFT OUTER JOIN show_foreign_key fk
|
|
244
|
+
ON constraint_cols.column_name = fk.columnname
|
|
245
|
+
WHERE constraints.table_name =UPPER('%s')"""
|
|
246
|
+
|
|
247
|
+
def columnsFromSchema(self, tableName, soClass):
|
|
248
|
+
colData = self.queryAll(self.GET_COLUMNS
|
|
249
|
+
% tableName)
|
|
250
|
+
|
|
251
|
+
results = []
|
|
252
|
+
keymap = {}
|
|
253
|
+
pkmap = {}
|
|
254
|
+
fkData = self.queryAll(self.GET_PK_AND_FK % tableName)
|
|
255
|
+
for _col, cons_type, refcol, reftable in fkData:
|
|
256
|
+
col_name = _col.lower()
|
|
257
|
+
pkmap[col_name] = False
|
|
258
|
+
if cons_type == 'R':
|
|
259
|
+
keymap[col_name] = reftable.lower()
|
|
260
|
+
|
|
261
|
+
elif cons_type == 'P':
|
|
262
|
+
pkmap[col_name] = True
|
|
263
|
+
|
|
264
|
+
if len(pkmap) == 0:
|
|
265
|
+
raise PrimaryKeyNotFounded(tableName)
|
|
266
|
+
|
|
267
|
+
for (field, nullAllowed, default, data_type, data_len,
|
|
268
|
+
data_scale) in colData:
|
|
269
|
+
# id is defined as primary key --> ok
|
|
270
|
+
# We let sqlobject raise error if the 'id' is used
|
|
271
|
+
# for another column.
|
|
272
|
+
field_name = field.lower()
|
|
273
|
+
if (field_name == soClass.sqlmeta.idName) and pkmap[field_name]:
|
|
274
|
+
continue
|
|
275
|
+
|
|
276
|
+
colClass, kw = self.guessClass(data_type, data_len, data_scale)
|
|
277
|
+
kw['name'] = field_name
|
|
278
|
+
kw['dbName'] = field
|
|
279
|
+
|
|
280
|
+
if nullAllowed == 'Y':
|
|
281
|
+
nullAllowed = False
|
|
282
|
+
else:
|
|
283
|
+
nullAllowed = True
|
|
284
|
+
|
|
285
|
+
kw['notNone'] = nullAllowed
|
|
286
|
+
if default is not None:
|
|
287
|
+
kw['default'] = default
|
|
288
|
+
|
|
289
|
+
if field_name in keymap:
|
|
290
|
+
kw['foreignKey'] = keymap[field_name]
|
|
291
|
+
|
|
292
|
+
results.append(colClass(**kw))
|
|
293
|
+
|
|
294
|
+
return results
|
|
295
|
+
|
|
296
|
+
_numericTypes = ['INTEGER', 'INT', 'SMALLINT']
|
|
297
|
+
_dateTypes = ['DATE', 'TIME', 'TIMESTAMP']
|
|
298
|
+
|
|
299
|
+
def guessClass(self, t, flength, fscale=None):
|
|
300
|
+
"""
|
|
301
|
+
An internal method that tries to figure out what Col subclass
|
|
302
|
+
is appropriate given whatever introspective information is
|
|
303
|
+
available -- both very database-specific.
|
|
304
|
+
"""
|
|
305
|
+
if t in self._numericTypes:
|
|
306
|
+
return col.IntCol, {}
|
|
307
|
+
# The type returned by the sapdb library for LONG is
|
|
308
|
+
# SapDB_LongReader To get the data call the read member with
|
|
309
|
+
# desired size (default =-1 means get all)
|
|
310
|
+
|
|
311
|
+
elif t.find('LONG') != -1:
|
|
312
|
+
return col.StringCol, {'length': flength,
|
|
313
|
+
'varchar': False}
|
|
314
|
+
elif t in self._dateTypes:
|
|
315
|
+
return col.DateTimeCol, {}
|
|
316
|
+
elif t == 'FIXED':
|
|
317
|
+
return col.CurrencyCol, {'size': flength,
|
|
318
|
+
'precision': fscale}
|
|
319
|
+
else:
|
|
320
|
+
return col.Col, {}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
This program is distributed in the hope that it will be useful,
|
|
2
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
3
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
4
|
+
GNU General Public License for more details.
|
|
5
|
+
|
|
6
|
+
Author: <ahmedmo@wanadoo.fr>
|
|
7
|
+
Edigram SA - Paris France
|
|
8
|
+
Tel:0144779400
|
|
9
|
+
|
|
10
|
+
SAPDBAPI installation
|
|
11
|
+
---------------------
|
|
12
|
+
|
|
13
|
+
The sapdb module can be downloaded from:
|
|
14
|
+
|
|
15
|
+
Win32
|
|
16
|
+
-----
|
|
17
|
+
|
|
18
|
+
ftp://ftp.sap.com/pub/sapdb/bin/win/sapdb-python-win32-7.4.03.33a.zip
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
Linux
|
|
22
|
+
-----
|
|
23
|
+
|
|
24
|
+
ftp://ftp.sap.com/pub/sapdb/bin/linux/sapdb-python-linux-i386-7.4.03.33a.tgz
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
Uncompress the archive and add the sapdb directory path to your PYTHONPATH.
|