Esempio n. 1
0
    def _type_map(self):
        type_map = sql.TypeMap()
        type_map[Long] = "INTEGER"
        type_map[Integer] = "INTEGER"
        type_map[Real] = "REAL"
        type_map[Boolean] = "BOOLEAN"
        type_map[Text] = "TEXT"
        type_map[Timestamp] = "TIMESTAMP"
        type_map[UUID] = "UUID"
        type_map[Geometry] = "GEOMETRY"

        return type_map
Esempio n. 2
0
    def _type_map(self):
        type_map = sql.TypeMap()
        type_map[Long] = "BIGINT"
        type_map[Integer] = "INTEGER"
        type_map[Real] = "DOUBLE PRECISION"
        type_map[Boolean] = "BOOLEAN"
        type_map[Text] = "TEXT"
        type_map[Timestamp] = "TIMESTAMP"
        type_map[UUID] = "UUID"
        type_map[Geometry] = "GEOGRAPHY"

        return type_map
Esempio n. 3
0
    def __init__(self,
                 connection_string="",
                 table_prefix="",
                 library="psycopg2"):
        self._connection = PostgresqlConnection(connection_string, library)
        self._library = library

        if table_prefix and not re.match(r"[a-z][_a-z]*(\.[a-z][_a-z]*)*",
                                         table_prefix):
            raise ValueError("invalid table_prefix %s" % table_prefix)
        self._table_prefix = table_prefix

        self._core_table_name = self._table_name("core")
        self._link_table_name = self._table_name("link")
        self._tag_table_name = self._table_name("tag")

        self._namespace_schemas = {}
        self._sql_builder = sql.SQLBuilder({}, sql.TypeMap(), {},
                                           self._table_name, self._placeholder,
                                           self._placeholder,
                                           self._rewriter_property)
Esempio n. 4
0
    def __init__(self,
                 connection_string="",
                 mod_spatialite_path="mod_spatialite",
                 table_prefix=""):
        dbapi2.register_converter("BOOLEAN", lambda x: bool(int(x)))
        dbapi2.register_adapter(bool, lambda x: int(x))

        dbapi2.register_converter("UUID", lambda x: uuid.UUID(x.decode()))
        dbapi2.register_adapter(uuid.UUID, lambda x: x.hex)

        dbapi2.register_converter("GEOMETRY", _cast_geometry)
        dbapi2.register_adapter(geometry.Point, _adapt_geometry)
        dbapi2.register_adapter(geometry.LineString, _adapt_geometry)
        dbapi2.register_adapter(geometry.Polygon, _adapt_geometry)
        dbapi2.register_adapter(geometry.MultiPoint, _adapt_geometry)
        dbapi2.register_adapter(geometry.MultiLineString, _adapt_geometry)
        dbapi2.register_adapter(geometry.MultiPolygon, _adapt_geometry)

        self._connection_string = connection_string
        self._connection = SQLiteConnection(connection_string,
                                            mod_spatialite_path, self)

        if table_prefix and not re.match(r"[a-z][_a-z]*(\.[a-z][_a-z]*)*",
                                         table_prefix):
            raise ValueError("invalid table_prefix %s" % table_prefix)
        self._table_prefix = table_prefix

        self._core_table_name = self._table_name("core")
        self._link_table_name = self._table_name("link")
        self._tag_table_name = self._table_name("tag")

        self._namespace_schemas = {}
        self._sql_builder = sql.SQLBuilder({}, sql.TypeMap(), {},
                                           self._table_name, self._placeholder,
                                           self._placeholder,
                                           self._rewriter_property)