當前位置: 首頁>>代碼示例>>Python>>正文


Python sqlite.DATE屬性代碼示例

本文整理匯總了Python中sqlalchemy.dialects.sqlite.DATE屬性的典型用法代碼示例。如果您正苦於以下問題:Python sqlite.DATE屬性的具體用法?Python sqlite.DATE怎麽用?Python sqlite.DATE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在sqlalchemy.dialects.sqlite的用法示例。


在下文中一共展示了sqlite.DATE屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _resolve_type_affinity

# 需要導入模塊: from sqlalchemy.dialects import sqlite [as 別名]
# 或者: from sqlalchemy.dialects.sqlite import DATE [as 別名]
def _resolve_type_affinity(self, type_):
        """Return a data type from a reflected column, using affinity tules.

        SQLite's goal for universal compatibility introduces some complexity
        during reflection, as a column's defined type might not actually be a
        type that SQLite understands - or indeed, my not be defined *at all*.
        Internally, SQLite handles this with a 'data type affinity' for each
        column definition, mapping to one of 'TEXT', 'NUMERIC', 'INTEGER',
        'REAL', or 'NONE' (raw bits). The algorithm that determines this is
        listed in http://www.sqlite.org/datatype3.html section 2.1.

        This method allows SQLAlchemy to support that algorithm, while still
        providing access to smarter reflection utilities by regcognizing
        column definitions that SQLite only supports through affinity (like
        DATE and DOUBLE).

        """
        match = re.match(r'([\w ]+)(\(.*?\))?', type_)
        if match:
            coltype = match.group(1)
            args = match.group(2)
        else:
            coltype = ''
            args = ''

        if coltype in self.ischema_names:
            coltype = self.ischema_names[coltype]
        elif 'INT' in coltype:
            coltype = sqltypes.INTEGER
        elif 'CHAR' in coltype or 'CLOB' in coltype or 'TEXT' in coltype:
            coltype = sqltypes.TEXT
        elif 'BLOB' in coltype or not coltype:
            coltype = sqltypes.NullType
        elif 'REAL' in coltype or 'FLOA' in coltype or 'DOUB' in coltype:
            coltype = sqltypes.REAL
        else:
            coltype = sqltypes.NUMERIC

        if args is not None:
            args = re.findall(r'(\d+)', args)
            try:
                coltype = coltype(*[int(a) for a in args])
            except TypeError:
                util.warn(
                    "Could not instantiate type %s with "
                    "reflected arguments %s; using no arguments." %
                    (coltype, args))
                coltype = coltype()
        else:
            coltype = coltype()

        return coltype 
開發者ID:jpush,項目名稱:jbox,代碼行數:54,代碼來源:base.py

示例2: _resolve_type_affinity

# 需要導入模塊: from sqlalchemy.dialects import sqlite [as 別名]
# 或者: from sqlalchemy.dialects.sqlite import DATE [as 別名]
def _resolve_type_affinity(self, type_):
        """Return a data type from a reflected column, using affinity tules.

        SQLite's goal for universal compatibility introduces some complexity
        during reflection, as a column's defined type might not actually be a
        type that SQLite understands - or indeed, my not be defined *at all*.
        Internally, SQLite handles this with a 'data type affinity' for each
        column definition, mapping to one of 'TEXT', 'NUMERIC', 'INTEGER',
        'REAL', or 'NONE' (raw bits). The algorithm that determines this is
        listed in http://www.sqlite.org/datatype3.html section 2.1.

        This method allows SQLAlchemy to support that algorithm, while still
        providing access to smarter reflection utilities by regcognizing
        column definitions that SQLite only supports through affinity (like
        DATE and DOUBLE).

        """
        match = re.match(r"([\w ]+)(\(.*?\))?", type_)
        if match:
            coltype = match.group(1)
            args = match.group(2)
        else:
            coltype = ""
            args = ""

        if coltype in self.ischema_names:
            coltype = self.ischema_names[coltype]
        elif "INT" in coltype:
            coltype = sqltypes.INTEGER
        elif "CHAR" in coltype or "CLOB" in coltype or "TEXT" in coltype:
            coltype = sqltypes.TEXT
        elif "BLOB" in coltype or not coltype:
            coltype = sqltypes.NullType
        elif "REAL" in coltype or "FLOA" in coltype or "DOUB" in coltype:
            coltype = sqltypes.REAL
        else:
            coltype = sqltypes.NUMERIC

        if args is not None:
            args = re.findall(r"(\d+)", args)
            try:
                coltype = coltype(*[int(a) for a in args])
            except TypeError:
                util.warn(
                    "Could not instantiate type %s with "
                    "reflected arguments %s; using no arguments."
                    % (coltype, args)
                )
                coltype = coltype()
        else:
            coltype = coltype()

        return coltype 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:55,代碼來源:base.py

示例3: _resolve_type_affinity

# 需要導入模塊: from sqlalchemy.dialects import sqlite [as 別名]
# 或者: from sqlalchemy.dialects.sqlite import DATE [as 別名]
def _resolve_type_affinity(self, type_):
        """Return a data type from a reflected column, using affinity tules.

        SQLite's goal for universal compatability introduces some complexity
        during reflection, as a column's defined type might not actually be a
        type that SQLite understands - or indeed, my not be defined *at all*.
        Internally, SQLite handles this with a 'data type affinity' for each
        column definition, mapping to one of 'TEXT', 'NUMERIC', 'INTEGER',
        'REAL', or 'NONE' (raw bits). The algorithm that determines this is
        listed in http://www.sqlite.org/datatype3.html section 2.1.

        This method allows SQLAlchemy to support that algorithm, while still
        providing access to smarter reflection utilities by regcognizing
        column definitions that SQLite only supports through affinity (like
        DATE and DOUBLE).

        """
        match = re.match(r'([\w ]+)(\(.*?\))?', type_)
        if match:
            coltype = match.group(1)
            args = match.group(2)
        else:
            coltype = ''
            args = ''

        if coltype in self.ischema_names:
            coltype = self.ischema_names[coltype]
        elif 'INT' in coltype:
            coltype = sqltypes.INTEGER
        elif 'CHAR' in coltype or 'CLOB' in coltype or 'TEXT' in coltype:
            coltype = sqltypes.TEXT
        elif 'BLOB' in coltype or not coltype:
            coltype = sqltypes.NullType
        elif 'REAL' in coltype or 'FLOA' in coltype or 'DOUB' in coltype:
            coltype = sqltypes.REAL
        else:
            coltype = sqltypes.NUMERIC

        if args is not None:
            args = re.findall(r'(\d+)', args)
            try:
                coltype = coltype(*[int(a) for a in args])
            except TypeError:
                util.warn(
                        "Could not instantiate type %s with "
                        "reflected arguments %s; using no arguments." %
                        (coltype, args))
                coltype = coltype()
        else:
            coltype = coltype()

        return coltype 
開發者ID:binhex,項目名稱:moviegrabber,代碼行數:54,代碼來源:base.py


注:本文中的sqlalchemy.dialects.sqlite.DATE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。