ado_consts.py 10 KB

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