__init__.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. from .apibase import apilevel, threadsafety, paramstyle
  8. from .apibase import Warning, Error, InterfaceError, DatabaseError, DataError, OperationalError, IntegrityError
  9. from .apibase import InternalError, ProgrammingError, NotSupportedError, FetchFailedError
  10. from .apibase import NUMBER, STRING, BINARY, DATETIME, ROWID
  11. from .adodbapi import connect, Connection, __version__, dateconverter, Cursor
  12. def Binary(aString):
  13. """This function constructs an object capable of holding a binary (long) string value. """
  14. return bytes(aString)
  15. def Date(year,month,day):
  16. "This function constructs an object holding a date value. "
  17. return dateconverter.Date(year,month,day)
  18. def Time(hour,minute,second):
  19. "This function constructs an object holding a time value. "
  20. return dateconverter.Time(hour,minute,second)
  21. def Timestamp(year,month,day,hour,minute,second):
  22. "This function constructs an object holding a time stamp value. "
  23. return dateconverter.Timestamp(year,month,day,hour,minute,second)
  24. def DateFromTicks(ticks):
  25. """This function constructs an object holding a date value from the given ticks value
  26. (number of seconds since the epoch; see the documentation of the standard Python time module for details). """
  27. return Date(*time.gmtime(ticks)[:3])
  28. def TimeFromTicks(ticks):
  29. """This function constructs an object holding a time value from the given ticks value
  30. (number of seconds since the epoch; see the documentation of the standard Python time module for details). """
  31. return Time(*time.gmtime(ticks)[3:6])
  32. def TimestampFromTicks(ticks):
  33. """This function constructs an object holding a time stamp value from the given
  34. ticks value (number of seconds since the epoch;
  35. see the documentation of the standard Python time module for details). """
  36. return Timestamp(*time.gmtime(ticks)[:6])
  37. version = 'adodbapi v' + __version__