Skip to content

Commit 29ddf6b

Browse files
committed
python27_32 add win32py module
1 parent a8ca9e2 commit 29ddf6b

603 files changed

Lines changed: 103957 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
2.54 MB
Binary file not shown.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
"""adodbapi - A python DB API 2.0 (PEP 249) interface to Microsoft ADO
2+
3+
Copyright (C) 2002 Henrik Ekelund, version 2.1 by Vernon Cole
4+
* http://sourceforge.net/projects/adodbapi
5+
"""
6+
import sys
7+
import time
8+
9+
if sys.version_info < (3,0): # in Python 2, define all symbols, just like the bad old way
10+
from apibase import *
11+
VariantConversionMap = MultiMap # old name. Should use apibase.MultiMap
12+
from ado_consts import *
13+
_makeByteBuffer = buffer
14+
else:
15+
# but if the user is running Python 3, then keep the dictionary clean
16+
from .apibase import apilevel, threadsafety, paramstyle
17+
from .apibase import Warning, Error, InterfaceError, DatabaseError, DataError, OperationalError, IntegrityError
18+
from .apibase import InternalError, ProgrammingError, NotSupportedError, FetchFailedError
19+
from .apibase import NUMBER, STRING, BINARY, DATETIME, ROWID
20+
_makeByteBuffer = bytes
21+
22+
from adodbapi import connect, Connection, __version__, dateconverter, Cursor
23+
24+
def Binary(aString):
25+
"""This function constructs an object capable of holding a binary (long) string value. """
26+
return _makeByteBuffer(aString)
27+
28+
def Date(year,month,day):
29+
"This function constructs an object holding a date value. "
30+
return dateconverter.Date(year,month,day)
31+
32+
def Time(hour,minute,second):
33+
"This function constructs an object holding a time value. "
34+
return dateconverter.Time(hour,minute,second)
35+
36+
def Timestamp(year,month,day,hour,minute,second):
37+
"This function constructs an object holding a time stamp value. "
38+
return dateconverter.Timestamp(year,month,day,hour,minute,second)
39+
40+
def DateFromTicks(ticks):
41+
"""This function constructs an object holding a date value from the given ticks value
42+
(number of seconds since the epoch; see the documentation of the standard Python time module for details). """
43+
return Date(*time.gmtime(ticks)[:3])
44+
45+
def TimeFromTicks(ticks):
46+
"""This function constructs an object holding a time value from the given ticks value
47+
(number of seconds since the epoch; see the documentation of the standard Python time module for details). """
48+
return Time(*time.gmtime(ticks)[3:6])
49+
50+
def TimestampFromTicks(ticks):
51+
"""This function constructs an object holding a time stamp value from the given
52+
ticks value (number of seconds since the epoch;
53+
see the documentation of the standard Python time module for details). """
54+
return Timestamp(*time.gmtime(ticks)[:6])
55+
56+
version = 'adodbapi v' + __version__
Lines changed: 276 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,276 @@
1+
# ADO enumerated constants documented on MSDN:
2+
# http://msdn.microsoft.com/en-us/library/ms678353(VS.85).aspx
3+
4+
# IsolationLevelEnum
5+
adXactUnspecified = -1
6+
adXactBrowse = 0x100
7+
adXactChaos = 0x10
8+
adXactCursorStability = 0x1000
9+
adXactIsolated = 0x100000
10+
adXactReadCommitted = 0x1000
11+
adXactReadUncommitted = 0x100
12+
adXactRepeatableRead = 0x10000
13+
adXactSerializable = 0x100000
14+
15+
# CursorLocationEnum
16+
adUseClient = 3
17+
adUseServer = 2
18+
19+
# CursorTypeEnum
20+
adOpenDynamic = 2
21+
adOpenForwardOnly = 0
22+
adOpenKeyset = 1
23+
adOpenStatic = 3
24+
adOpenUnspecified = -1
25+
26+
# CommandTypeEnum
27+
adCmdText = 1
28+
adCmdStoredProc = 4
29+
adSchemaTables = 20
30+
31+
# ParameterDirectionEnum
32+
adParamInput = 1
33+
adParamInputOutput = 3
34+
adParamOutput = 2
35+
adParamReturnValue = 4
36+
adParamUnknown = 0
37+
directions = {
38+
0: 'Unknown',
39+
1: 'Input',
40+
2: 'Output',
41+
3: 'InputOutput',
42+
4: 'Return',
43+
}
44+
def ado_direction_name(ado_dir):
45+
try:
46+
return 'adParam' + directions[ado_dir]
47+
except:
48+
return 'unknown direction ('+str(ado_dir)+')'
49+
50+
# ObjectStateEnum
51+
adStateClosed = 0
52+
adStateOpen = 1
53+
adStateConnecting = 2
54+
adStateExecuting = 4
55+
adStateFetching = 8
56+
57+
# FieldAttributeEnum
58+
adFldMayBeNull = 0x40
59+
60+
# ConnectModeEnum
61+
adModeUnknown = 0
62+
adModeRead = 1
63+
adModeWrite = 2
64+
adModeReadWrite = 3
65+
adModeShareDenyRead = 4
66+
adModeShareDenyWrite = 8
67+
adModeShareExclusive = 12
68+
adModeShareDenyNone = 16
69+
adModeRecursive = 0x400000
70+
71+
# XactAttributeEnum
72+
adXactCommitRetaining = 131072
73+
adXactAbortRetaining = 262144
74+
75+
ado_error_TIMEOUT = -2147217871
76+
77+
# DataTypeEnum - ADO Data types documented at:
78+
# http://msdn2.microsoft.com/en-us/library/ms675318.aspx
79+
adArray = 0x2000
80+
adEmpty = 0x0
81+
adBSTR = 0x8
82+
adBigInt = 0x14
83+
adBinary = 0x80
84+
adBoolean = 0xb
85+
adChapter = 0x88
86+
adChar = 0x81
87+
adCurrency = 0x6
88+
adDBDate = 0x85
89+
adDBTime = 0x86
90+
adDBTimeStamp = 0x87
91+
adDate = 0x7
92+
adDecimal = 0xe
93+
adDouble = 0x5
94+
adError = 0xa
95+
adFileTime = 0x40
96+
adGUID = 0x48
97+
adIDispatch = 0x9
98+
adIUnknown = 0xd
99+
adInteger = 0x3
100+
adLongVarBinary = 0xcd
101+
adLongVarChar = 0xc9
102+
adLongVarWChar = 0xcb
103+
adNumeric = 0x83
104+
adPropVariant = 0x8a
105+
adSingle = 0x4
106+
adSmallInt = 0x2
107+
adTinyInt = 0x10
108+
adUnsignedBigInt = 0x15
109+
adUnsignedInt = 0x13
110+
adUnsignedSmallInt = 0x12
111+
adUnsignedTinyInt = 0x11
112+
adUserDefined = 0x84
113+
adVarBinary = 0xCC
114+
adVarChar = 0xC8
115+
adVarNumeric = 0x8B
116+
adVarWChar = 0xCA
117+
adVariant = 0xC
118+
adWChar = 0x82
119+
# Additional constants used by introspection but not ADO itself
120+
AUTO_FIELD_MARKER = -1000
121+
122+
adTypeNames = {
123+
adBSTR: 'adBSTR',
124+
adBigInt: 'adBigInt',
125+
adBinary: 'adBinary',
126+
adBoolean: 'adBoolean',
127+
adChapter: 'adChapter',
128+
adChar: 'adChar',
129+
adCurrency: 'adCurrency',
130+
adDBDate: 'adDBDate',
131+
adDBTime: 'adDBTime',
132+
adDBTimeStamp: 'adDBTimeStamp',
133+
adDate: 'adDate',
134+
adDecimal: 'adDecimal',
135+
adDouble: 'adDouble',
136+
adEmpty: 'adEmpty',
137+
adError: 'adError',
138+
adFileTime: 'adFileTime',
139+
adGUID: 'adGUID',
140+
adIDispatch: 'adIDispatch',
141+
adIUnknown: 'adIUnknown',
142+
adInteger: 'adInteger',
143+
adLongVarBinary: 'adLongVarBinary',
144+
adLongVarChar: 'adLongVarChar',
145+
adLongVarWChar: 'adLongVarWChar',
146+
adNumeric: 'adNumeric',
147+
adPropVariant: 'adPropVariant',
148+
adSingle: 'adSingle',
149+
adSmallInt: 'adSmallInt',
150+
adTinyInt: 'adTinyInt',
151+
adUnsignedBigInt: 'adUnsignedBigInt',
152+
adUnsignedInt: 'adUnsignedInt',
153+
adUnsignedSmallInt: 'adUnsignedSmallInt',
154+
adUnsignedTinyInt: 'adUnsignedTinyInt',
155+
adUserDefined: 'adUserDefined',
156+
adVarBinary: 'adVarBinary',
157+
adVarChar: 'adVarChar',
158+
adVarNumeric: 'adVarNumeric',
159+
adVarWChar: 'adVarWChar',
160+
adVariant: 'adVariant',
161+
adWChar: 'adWChar',
162+
}
163+
164+
def ado_type_name(ado_type):
165+
return adTypeNames.get(ado_type, 'unknown type ('+str(ado_type)+')')
166+
167+
# here in decimal, sorted by value
168+
#adEmpty 0 Specifies no value (DBTYPE_EMPTY).
169+
#adSmallInt 2 Indicates a two-byte signed integer (DBTYPE_I2).
170+
#adInteger 3 Indicates a four-byte signed integer (DBTYPE_I4).
171+
#adSingle 4 Indicates a single-precision floating-point value (DBTYPE_R4).
172+
#adDouble 5 Indicates a double-precision floating-point value (DBTYPE_R8).
173+
#adCurrency 6 Indicates a currency value (DBTYPE_CY). Currency is a fixed-point number
174+
# with four digits to the right of the decimal point. It is stored in an eight-byte signed integer scaled by 10,000.
175+
#adDate 7 Indicates a date value (DBTYPE_DATE). A date is stored as a double, the whole part of which is
176+
# the number of days since December 30, 1899, and the fractional part of which is the fraction of a day.
177+
#adBSTR 8 Indicates a null-terminated character string (Unicode) (DBTYPE_BSTR).
178+
#adIDispatch 9 Indicates a pointer to an IDispatch interface on a COM object (DBTYPE_IDISPATCH).
179+
#adError 10 Indicates a 32-bit error code (DBTYPE_ERROR).
180+
#adBoolean 11 Indicates a boolean value (DBTYPE_BOOL).
181+
#adVariant 12 Indicates an Automation Variant (DBTYPE_VARIANT).
182+
#adIUnknown 13 Indicates a pointer to an IUnknown interface on a COM object (DBTYPE_IUNKNOWN).
183+
#adDecimal 14 Indicates an exact numeric value with a fixed precision and scale (DBTYPE_DECIMAL).
184+
#adTinyInt 16 Indicates a one-byte signed integer (DBTYPE_I1).
185+
#adUnsignedTinyInt 17 Indicates a one-byte unsigned integer (DBTYPE_UI1).
186+
#adUnsignedSmallInt 18 Indicates a two-byte unsigned integer (DBTYPE_UI2).
187+
#adUnsignedInt 19 Indicates a four-byte unsigned integer (DBTYPE_UI4).
188+
#adBigInt 20 Indicates an eight-byte signed integer (DBTYPE_I8).
189+
#adUnsignedBigInt 21 Indicates an eight-byte unsigned integer (DBTYPE_UI8).
190+
#adFileTime 64 Indicates a 64-bit value representing the number of 100-nanosecond intervals since
191+
# January 1, 1601 (DBTYPE_FILETIME).
192+
#adGUID 72 Indicates a globally unique identifier (GUID) (DBTYPE_GUID).
193+
#adBinary 128 Indicates a binary value (DBTYPE_BYTES).
194+
#adChar 129 Indicates a string value (DBTYPE_STR).
195+
#adWChar 130 Indicates a null-terminated Unicode character string (DBTYPE_WSTR).
196+
#adNumeric 131 Indicates an exact numeric value with a fixed precision and scale (DBTYPE_NUMERIC).
197+
# adUserDefined 132 Indicates a user-defined variable (DBTYPE_UDT).
198+
#adUserDefined 132 Indicates a user-defined variable (DBTYPE_UDT).
199+
#adDBDate 133 Indicates a date value (yyyymmdd) (DBTYPE_DBDATE).
200+
#adDBTime 134 Indicates a time value (hhmmss) (DBTYPE_DBTIME).
201+
#adDBTimeStamp 135 Indicates a date/time stamp (yyyymmddhhmmss plus a fraction in billionths) (DBTYPE_DBTIMESTAMP).
202+
#adChapter 136 Indicates a four-byte chapter value that identifies rows in a child rowset (DBTYPE_HCHAPTER).
203+
#adPropVariant 138 Indicates an Automation PROPVARIANT (DBTYPE_PROP_VARIANT).
204+
#adVarNumeric 139 Indicates a numeric value (Parameter object only).
205+
#adVarChar 200 Indicates a string value (Parameter object only).
206+
#adLongVarChar 201 Indicates a long string value (Parameter object only).
207+
#adVarWChar 202 Indicates a null-terminated Unicode character string (Parameter object only).
208+
#adLongVarWChar 203 Indicates a long null-terminated Unicode string value (Parameter object only).
209+
#adVarBinary 204 Indicates a binary value (Parameter object only).
210+
#adLongVarBinary 205 Indicates a long binary value (Parameter object only).
211+
#adArray (Does not apply to ADOX.) 0x2000 A flag value, always combined with another data type constant,
212+
# that indicates an array of that other data type.
213+
214+
# Error codes to names
215+
adoErrors= {
216+
0xe7b :'adErrBoundToCommand',
217+
0xe94 :'adErrCannotComplete',
218+
0xea4 :'adErrCantChangeConnection',
219+
0xc94 :'adErrCantChangeProvider',
220+
0xe8c :'adErrCantConvertvalue',
221+
0xe8d :'adErrCantCreate',
222+
0xea3 :'adErrCatalogNotSet',
223+
0xe8e :'adErrColumnNotOnThisRow',
224+
0xd5d :'adErrDataConversion',
225+
0xe89 :'adErrDataOverflow',
226+
0xe9a :'adErrDelResOutOfScope',
227+
0xea6 :'adErrDenyNotSupported',
228+
0xea7 :'adErrDenyTypeNotSupported',
229+
0xcb3 :'adErrFeatureNotAvailable',
230+
0xea5 :'adErrFieldsUpdateFailed',
231+
0xc93 :'adErrIllegalOperation',
232+
0xcae :'adErrInTransaction',
233+
0xe87 :'adErrIntegrityViolation',
234+
0xbb9 :'adErrInvalidArgument',
235+
0xe7d :'adErrInvalidConnection',
236+
0xe7c :'adErrInvalidParamInfo',
237+
0xe82 :'adErrInvalidTransaction',
238+
0xe91 :'adErrInvalidURL',
239+
0xcc1 :'adErrItemNotFound',
240+
0xbcd :'adErrNoCurrentRecord',
241+
0xe83 :'adErrNotExecuting',
242+
0xe7e :'adErrNotReentrant',
243+
0xe78 :'adErrObjectClosed',
244+
0xd27 :'adErrObjectInCollection',
245+
0xd5c :'adErrObjectNotSet',
246+
0xe79 :'adErrObjectOpen',
247+
0xbba :'adErrOpeningFile',
248+
0xe80 :'adErrOperationCancelled',
249+
0xe96 :'adErrOutOfSpace',
250+
0xe88 :'adErrPermissionDenied',
251+
0xe9e :'adErrPropConflicting',
252+
0xe9b :'adErrPropInvalidColumn',
253+
0xe9c :'adErrPropInvalidOption',
254+
0xe9d :'adErrPropInvalidValue',
255+
0xe9f :'adErrPropNotAllSettable',
256+
0xea0 :'adErrPropNotSet',
257+
0xea1 :'adErrPropNotSettable',
258+
0xea2 :'adErrPropNotSupported',
259+
0xbb8 :'adErrProviderFailed',
260+
0xe7a :'adErrProviderNotFound',
261+
0xbbb :'adErrReadFile',
262+
0xe93 :'adErrResourceExists',
263+
0xe92 :'adErrResourceLocked',
264+
0xe97 :'adErrResourceOutOfScope',
265+
0xe8a :'adErrSchemaViolation',
266+
0xe8b :'adErrSignMismatch',
267+
0xe81 :'adErrStillConnecting',
268+
0xe7f :'adErrStillExecuting',
269+
0xe90 :'adErrTreePermissionDenied',
270+
0xe8f :'adErrURLDoesNotExist',
271+
0xe99 :'adErrURLNamedRowDoesNotExist',
272+
0xe98 :'adErrUnavailable',
273+
0xe84 :'adErrUnsafeOperation',
274+
0xe95 :'adErrVolumeNotFound',
275+
0xbbc :'adErrWriteFile'
276+
}

0 commit comments

Comments
 (0)