Date
is a class within the sqlalchemy.types
module of the SQLAlchemy project.
BOOLEAN,
Boolean,
DATETIME,
Date,
DateTime,
Enum,
FLOAT,
Float,
INTEGER,
Integer,
Interval,
NULLTYPE,
NullType,
String,
TEXT,
TIME,
Text,
Time,
TypeEngine,
UserDefinedType,
and to_instance
are several other callables with code examples from the same sqlalchemy.types
package.
SQLAthanor (PyPI package information and project documentation) is a SQLAlchemy extension that provides serialization and deserialization support for JSON, CSV, YAML and Python dictionaries. This project is similar to Marshmallow with one major difference: SQLAthanor works through SQLAlchemy models while Marshmallow is less coupled to SQLAlchemy because it requires separate representations of the serialization objects. Both libraries have their uses depending on whether the project plans to use SQLAlchemy for object representations or would prefer to avoid that couping. SQLAthanor is open sourced under the MIT license.
SQLAthanor / sqlathanor / default_deserializers.py
# default_deserializers.py
import datetime
import io
from validator_collection import validators, checkers
from sqlathanor._compat import json
from sqlathanor.utilities import format_to_tuple, get_class_type_key, \
raise_UnsupportedSerializationError, raise_UnsupportedDeserializationError
from sqlathanor.errors import UnsupportedValueTypeError
from sqlalchemy.types import Boolean, Date, DateTime, Float, Integer, Text, Time, Interval
DEFAULT_PYTHON_SQL_TYPE_MAPPING = {
'bool': Boolean,
'str': Text,
'int': Integer,
'float': Float,
'datetime': DateTime,
'date': Date,
'time': Time,
'timedelta': Interval
}
def get_default_deserializer(class_attribute = None,
format = None):
format_to_tuple(format)
format = format.lower()
class_type_key = get_class_type_key(class_attribute, None)
deserializer_dict = DEFAULT_DESERIALIZERS.get(class_type_key, None)
if deserializer_dict is None:
return None
## ... source file continues with no further Date examples...