mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-29 12:23:42 +03:00
Added typecasters for arrays of specific MX/Py time-related types.
This commit is contained in:
parent
c8aef26e15
commit
e8c2a14362
|
@ -1,3 +1,7 @@
|
|||
2010-05-04 Daniele Varrazzo <daniele.varrazzo@gmail.com>
|
||||
|
||||
* Added typecasters for arrays of specific MX/Py time-related types.
|
||||
|
||||
2010-05-03 Daniele Varrazzo <daniele.varrazzo@gmail.com>
|
||||
|
||||
* psycopg/adapter_binary.c: Adapt buffer objects using an explicit cast on
|
||||
|
|
|
@ -537,6 +537,10 @@ from the database. See :ref:`unicode-handling` for details.
|
|||
PYDATETIME
|
||||
PYINTERVAL
|
||||
PYTIME
|
||||
PYDATEARRAY
|
||||
PYDATETIMEARRAY
|
||||
PYINTERVALARRAY
|
||||
PYTIMEARRAY
|
||||
|
||||
Typecasters to convert time-related data types to Python `!datetime`
|
||||
objects.
|
||||
|
@ -545,6 +549,10 @@ from the database. See :ref:`unicode-handling` for details.
|
|||
MXDATETIME
|
||||
MXINTERVAL
|
||||
MXTIME
|
||||
MXDATEARRAY
|
||||
MXDATETIMEARRAY
|
||||
MXINTERVALARRAY
|
||||
MXTIMEARRAY
|
||||
|
||||
Typecasters to convert time-related data types to `mx.DateTime`_ objects.
|
||||
Only available if Psycopg was compiled with `!mx` support.
|
||||
|
|
|
@ -42,6 +42,7 @@ from _psycopg import UNICODEARRAY
|
|||
from _psycopg import Binary, Boolean, Float, QuotedString, AsIs
|
||||
try:
|
||||
from _psycopg import MXDATE, MXDATETIME, MXINTERVAL, MXTIME
|
||||
from _psycopg import MXDATEARRAY, MXDATETIMEARRAY, MXINTERVALARRAY, MXTIMEARRAY
|
||||
from _psycopg import DateFromMx, TimeFromMx, TimestampFromMx
|
||||
from _psycopg import IntervalFromMx
|
||||
except:
|
||||
|
@ -49,6 +50,7 @@ except:
|
|||
|
||||
try:
|
||||
from _psycopg import PYDATE, PYDATETIME, PYINTERVAL, PYTIME
|
||||
from _psycopg import PYDATEARRAY, PYDATETIMEARRAY, PYINTERVALARRAY, PYTIMEARRAY
|
||||
from _psycopg import DateFromPy, TimeFromPy, TimestampFromPy
|
||||
from _psycopg import IntervalFromPy
|
||||
except:
|
||||
|
|
|
@ -182,6 +182,10 @@ typecast_parse_time(const char* s, const char** t, Py_ssize_t* len,
|
|||
#include "psycopg/typecast_array.c"
|
||||
#include "psycopg/typecast_builtins.c"
|
||||
|
||||
#define typecast_PYDATETIMEARRAY_cast typecast_GENERIC_ARRAY_cast
|
||||
#define typecast_PYDATEARRAY_cast typecast_GENERIC_ARRAY_cast
|
||||
#define typecast_PYTIMEARRAY_cast typecast_GENERIC_ARRAY_cast
|
||||
#define typecast_PYINTERVALARRAY_cast typecast_GENERIC_ARRAY_cast
|
||||
|
||||
/* a list of initializers, used to make the typecasters accessible anyway */
|
||||
static typecastObject_initlist typecast_pydatetime[] = {
|
||||
|
@ -189,16 +193,29 @@ static typecastObject_initlist typecast_pydatetime[] = {
|
|||
{"PYTIME", typecast_TIME_types, typecast_PYTIME_cast},
|
||||
{"PYDATE", typecast_DATE_types, typecast_PYDATE_cast},
|
||||
{"PYINTERVAL", typecast_INTERVAL_types, typecast_PYINTERVAL_cast},
|
||||
{"PYDATETIMEARRAY", typecast_DATETIMEARRAY_types, typecast_PYDATETIMEARRAY_cast, "PYDATETIME"},
|
||||
{"PYTIMEARRAY", typecast_TIMEARRAY_types, typecast_PYTIMEARRAY_cast, "PYTIME"},
|
||||
{"PYDATEARRAY", typecast_DATEARRAY_types, typecast_PYDATEARRAY_cast, "PYDATE"},
|
||||
{"PYINTERVALARRAY", typecast_INTERVALARRAY_types, typecast_PYINTERVALARRAY_cast, "PYINTERVAL"},
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
/* a list of initializers, used to make the typecasters accessible anyway */
|
||||
#ifdef HAVE_MXDATETIME
|
||||
#define typecast_MXDATETIMEARRAY_cast typecast_GENERIC_ARRAY_cast
|
||||
#define typecast_MXDATEARRAY_cast typecast_GENERIC_ARRAY_cast
|
||||
#define typecast_MXTIMEARRAY_cast typecast_GENERIC_ARRAY_cast
|
||||
#define typecast_MXINTERVALARRAY_cast typecast_GENERIC_ARRAY_cast
|
||||
|
||||
/* a list of initializers, used to make the typecasters accessible anyway */
|
||||
static typecastObject_initlist typecast_mxdatetime[] = {
|
||||
{"MXDATETIME", typecast_DATETIME_types, typecast_MXDATE_cast},
|
||||
{"MXTIME", typecast_TIME_types, typecast_MXTIME_cast},
|
||||
{"MXDATE", typecast_DATE_types, typecast_MXDATE_cast},
|
||||
{"MXINTERVAL", typecast_INTERVAL_types, typecast_MXINTERVAL_cast},
|
||||
{"MXDATETIMEARRAY", typecast_DATETIMEARRAY_types, typecast_MXDATETIMEARRAY_cast, "MXDATETIME"},
|
||||
{"MXTIMEARRAY", typecast_TIMEARRAY_types, typecast_MXTIMEARRAY_cast, "MXTIME"},
|
||||
{"MXDATEARRAY", typecast_DATEARRAY_types, typecast_MXDATEARRAY_cast, "MXDATE"},
|
||||
{"MXINTERVALARRAY", typecast_INTERVALARRAY_types, typecast_MXINTERVALARRAY_cast, "MXINTERVAL"},
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user