__init__.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. """adodbapi - A python DB API 2.0 (PEP 249) interface to Microsoft ADO
  2. Copyright (C) 2002 Henrik Ekelund, version 2.1 by Vernon Cole
  3. * http://sourceforge.net/projects/adodbapi
  4. """
  5. import sys
  6. import time
  7. if sys.version_info < (3,0): # in Python 2, define all symbols, just like the bad old way
  8. from apibase import *
  9. VariantConversionMap = MultiMap # old name. Should use apibase.MultiMap
  10. from ado_consts import *
  11. _makeByteBuffer = buffer
  12. else:
  13. # but if the user is running Python 3, then keep the dictionary clean
  14. from .apibase import apilevel, threadsafety, paramstyle
  15. from .apibase import Warning, Error, InterfaceError, DatabaseError, DataError, OperationalError, IntegrityError
  16. from .apibase import InternalError, ProgrammingError, NotSupportedError, FetchFailedError
  17. from .apibase import NUMBER, STRING, BINARY, DATETIME, ROWID
  18. _makeByteBuffer = bytes
  19. from adodbapi import connect, Connection, __version__, dateconverter, Cursor
  20. def Binary(aString):
  21. """This function constructs an object capable of holding a binary (long) string value. """
  22. return _makeByteBuffer(aString)
  23. def Date(year,month,day):
  24. "This function constructs an object holding a date value. "
  25. return dateconverter.Date(year,month,day)
  26. def Time(hour,minute,second):
  27. "This function constructs an object holding a time value. "
  28. return dateconverter.Time(hour,minute,second)
  29. def Timestamp(year,month,day,hour,minute,second):
  30. "This function constructs an object holding a time stamp value. "
  31. return dateconverter.Timestamp(year,month,day,hour,minute,second)
  32. def DateFromTicks(ticks):
  33. """This function constructs an object holding a date value from the given ticks value
  34. (number of seconds since the epoch; see the documentation of the standard Python time module for details). """
  35. return Date(*time.gmtime(ticks)[:3])
  36. def TimeFromTicks(ticks):
  37. """This function constructs an object holding a time value from the given ticks value
  38. (number of seconds since the epoch; see the documentation of the standard Python time module for details). """
  39. return Time(*time.gmtime(ticks)[3:6])
  40. def TimestampFromTicks(ticks):
  41. """This function constructs an object holding a time stamp value from the given
  42. ticks value (number of seconds since the epoch;
  43. see the documentation of the standard Python time module for details). """
  44. return Timestamp(*time.gmtime(ticks)[:6])
  45. version = 'adodbapi v' + __version__