Python sqlalchemy.exc 模块,NoSuchTableError() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用sqlalchemy.exc.NoSuchTableError()

项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
def get_table_id(self, connection, table_name, schema=None, **kw):
        """Fetch the id for schema.table_name.

        Several reflection methods require the table id.  The idea for using
        this method is that it can be fetched one time and cached for
        subsequent calls.

        """

        table_id = None
        if schema is None:
            schema = self.default_schema_name

        TABLEID_SQL = text("""
          SELECT o.id AS id
          FROM sysobjects o JOIN sysusers u ON o.uid=u.uid
          WHERE u.name = :schema_name
              AND o.name = :table_name
              AND o.type in ('U', 'V')
        """)

        if util.py2k:
            if isinstance(schema, unicode):
                schema = schema.encode("ascii")
            if isinstance(table_name, unicode):
                table_name = table_name.encode("ascii")
        result = connection.execute(TABLEID_SQL,
                                    schema_name=schema,
                                    table_name=table_name)
        table_id = result.scalar()
        if table_id is None:
            raise exc.NoSuchTableError(table_name)
        return table_id
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
def has_table(self, connection, table_name, schema=None):
        try:
            self.get_table_id(connection, table_name, schema)
        except exc.NoSuchTableError:
            return False
        else:
            return True
项目:QXSConsolas    作者:qxsch    | 项目源码 | 文件源码
def get_table_id(self, connection, table_name, schema=None, **kw):
        """Fetch the id for schema.table_name.

        Several reflection methods require the table id.  The idea for using
        this method is that it can be fetched one time and cached for
        subsequent calls.

        """

        table_id = None
        if schema is None:
            schema = self.default_schema_name

        TABLEID_SQL = text("""
          SELECT o.id AS id
          FROM sysobjects o JOIN sysusers u ON o.uid=u.uid
          WHERE u.name = :schema_name
              AND o.name = :table_name
              AND o.type in ('U', 'V')
        """)

        if util.py2k:
            if isinstance(schema, unicode):
                schema = schema.encode("ascii")
            if isinstance(table_name, unicode):
                table_name = table_name.encode("ascii")
        result = connection.execute(TABLEID_SQL,
                                    schema_name=schema,
                                    table_name=table_name)
        table_id = result.scalar()
        if table_id is None:
            raise exc.NoSuchTableError(table_name)
        return table_id
项目:QXSConsolas    作者:qxsch    | 项目源码 | 文件源码
def has_table(self, connection, table_name, schema=None):
        try:
            self.get_table_id(connection, table_name, schema)
        except exc.NoSuchTableError:
            return False
        else:
            return True
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def get_table_id(self, connection, table_name, schema=None, **kw):
        """Fetch the id for schema.table_name.

        Several reflection methods require the table id.  The idea for using
        this method is that it can be fetched one time and cached for
        subsequent calls.

        """

        table_id = None
        if schema is None:
            schema = self.default_schema_name

        TABLEID_SQL = text("""
          SELECT o.id AS id
          FROM sysobjects o JOIN sysusers u ON o.uid=u.uid
          WHERE u.name = :schema_name
              AND o.name = :table_name
              AND o.type in ('U', 'V')
        """)

        if util.py2k:
            if isinstance(schema, unicode):
                schema = schema.encode("ascii")
            if isinstance(table_name, unicode):
                table_name = table_name.encode("ascii")
        result = connection.execute(TABLEID_SQL,
                                    schema_name=schema,
                                    table_name=table_name)
        table_id = result.scalar()
        if table_id is None:
            raise exc.NoSuchTableError(table_name)
        return table_id
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def has_table(self, connection, table_name, schema=None):
        try:
            self.get_table_id(connection, table_name, schema)
        except exc.NoSuchTableError:
            return False
        else:
            return True
项目:PyAthena    作者:laughingman7743    | 项目源码 | 文件源码
def has_table(self, connection, table_name, schema=None):
        try:
            self.get_columns(connection, table_name, schema)
            return True
        except NoSuchTableError:
            return False
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def get_table_id(self, connection, table_name, schema=None, **kw):
        """Fetch the id for schema.table_name.

        Several reflection methods require the table id.  The idea for using
        this method is that it can be fetched one time and cached for
        subsequent calls.

        """

        table_id = None
        if schema is None:
            schema = self.default_schema_name

        TABLEID_SQL = text("""
          SELECT o.id AS id
          FROM sysobjects o JOIN sysusers u ON o.uid=u.uid
          WHERE u.name = :schema_name
              AND o.name = :table_name
              AND o.type in ('U', 'V')
        """)

        if util.py2k:
            if isinstance(schema, unicode):
                schema = schema.encode("ascii")
            if isinstance(table_name, unicode):
                table_name = table_name.encode("ascii")
        result = connection.execute(TABLEID_SQL,
                                    schema_name=schema,
                                    table_name=table_name)
        table_id = result.scalar()
        if table_id is None:
            raise exc.NoSuchTableError(table_name)
        return table_id
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def has_table(self, connection, table_name, schema=None):
        try:
            self.get_table_id(connection, table_name, schema)
        except exc.NoSuchTableError:
            return False
        else:
            return True
项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
def get_table_id(self, connection, table_name, schema=None, **kw):
        """Fetch the id for schema.table_name.

        Several reflection methods require the table id.  The idea for using
        this method is that it can be fetched one time and cached for
        subsequent calls.

        """

        table_id = None
        if schema is None:
            schema = self.default_schema_name

        TABLEID_SQL = text("""
          SELECT o.id AS id
          FROM sysobjects o JOIN sysusers u ON o.uid=u.uid
          WHERE u.name = :schema_name
              AND o.name = :table_name
              AND o.type in ('U', 'V')
        """)

        if util.py2k:
            if isinstance(schema, unicode):
                schema = schema.encode("ascii")
            if isinstance(table_name, unicode):
                table_name = table_name.encode("ascii")
        result = connection.execute(TABLEID_SQL,
                                    schema_name=schema,
                                    table_name=table_name)
        table_id = result.scalar()
        if table_id is None:
            raise exc.NoSuchTableError(table_name)
        return table_id
项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
def has_table(self, connection, table_name, schema=None):
        try:
            self.get_table_id(connection, table_name, schema)
        except exc.NoSuchTableError:
            return False
        else:
            return True
项目:ShelbySearch    作者:Agentscreech    | 项目源码 | 文件源码
def get_table_id(self, connection, table_name, schema=None, **kw):
        """Fetch the id for schema.table_name.

        Several reflection methods require the table id.  The idea for using
        this method is that it can be fetched one time and cached for
        subsequent calls.

        """

        table_id = None
        if schema is None:
            schema = self.default_schema_name

        TABLEID_SQL = text("""
          SELECT o.id AS id
          FROM sysobjects o JOIN sysusers u ON o.uid=u.uid
          WHERE u.name = :schema_name
              AND o.name = :table_name
              AND o.type in ('U', 'V')
        """)

        if util.py2k:
            if isinstance(schema, unicode):
                schema = schema.encode("ascii")
            if isinstance(table_name, unicode):
                table_name = table_name.encode("ascii")
        result = connection.execute(TABLEID_SQL,
                                    schema_name=schema,
                                    table_name=table_name)
        table_id = result.scalar()
        if table_id is None:
            raise exc.NoSuchTableError(table_name)
        return table_id
项目:ShelbySearch    作者:Agentscreech    | 项目源码 | 文件源码
def has_table(self, connection, table_name, schema=None):
        try:
            self.get_table_id(connection, table_name, schema)
        except exc.NoSuchTableError:
            return False
        else:
            return True
项目:pyetje    作者:rorlika    | 项目源码 | 文件源码
def get_table_id(self, connection, table_name, schema=None, **kw):
        """Fetch the id for schema.table_name.

        Several reflection methods require the table id.  The idea for using
        this method is that it can be fetched one time and cached for
        subsequent calls.

        """

        table_id = None
        if schema is None:
            schema = self.default_schema_name

        TABLEID_SQL = text("""
          SELECT o.id AS id
          FROM sysobjects o JOIN sysusers u ON o.uid=u.uid
          WHERE u.name = :schema_name
              AND o.name = :table_name
              AND o.type in ('U', 'V')
        """)

        # Py2K
        if isinstance(schema, unicode):
            schema = schema.encode("ascii")
        if isinstance(table_name, unicode):
            table_name = table_name.encode("ascii")
        # end Py2K
        result = connection.execute(TABLEID_SQL,
                                    schema_name=schema,
                                    table_name=table_name)
        table_id = result.scalar()
        if table_id is None:
            raise exc.NoSuchTableError(table_name)
        return table_id
项目:pyetje    作者:rorlika    | 项目源码 | 文件源码
def has_table(self, connection, table_name, schema=None):
        try:
            self.get_table_id(connection, table_name, schema)
        except exc.NoSuchTableError:
            return False
        else:
            return True
项目:Price-Comparator    作者:Thejas-1    | 项目源码 | 文件源码
def get_table_id(self, connection, table_name, schema=None, **kw):
        """Fetch the id for schema.table_name.

        Several reflection methods require the table id.  The idea for using
        this method is that it can be fetched one time and cached for
        subsequent calls.

        """

        table_id = None
        if schema is None:
            schema = self.default_schema_name

        TABLEID_SQL = text("""
          SELECT o.id AS id
          FROM sysobjects o JOIN sysusers u ON o.uid=u.uid
          WHERE u.name = :schema_name
              AND o.name = :table_name
              AND o.type in ('U', 'V')
        """)

        if util.py2k:
            if isinstance(schema, unicode):
                schema = schema.encode("ascii")
            if isinstance(table_name, unicode):
                table_name = table_name.encode("ascii")
        result = connection.execute(TABLEID_SQL,
                                    schema_name=schema,
                                    table_name=table_name)
        table_id = result.scalar()
        if table_id is None:
            raise exc.NoSuchTableError(table_name)
        return table_id
项目:Price-Comparator    作者:Thejas-1    | 项目源码 | 文件源码
def has_table(self, connection, table_name, schema=None):
        try:
            self.get_table_id(connection, table_name, schema)
        except exc.NoSuchTableError:
            return False
        else:
            return True
项目:sadrill    作者:JohnOmernik    | 项目源码 | 文件源码
def has_table(self, connection, table_name, schema=None):
        try:
            self._get_table_columns(connection, table_name, schema)
            return True
        except exc.NoSuchTableError:
            return False
项目:Flask-NvRay-Blog    作者:rui7157    | 项目源码 | 文件源码
def get_table_id(self, connection, table_name, schema=None, **kw):
        """Fetch the id for schema.table_name.

        Several reflection methods require the table id.  The idea for using
        this method is that it can be fetched one time and cached for
        subsequent calls.

        """

        table_id = None
        if schema is None:
            schema = self.default_schema_name

        TABLEID_SQL = text("""
          SELECT o.id AS id
          FROM sysobjects o JOIN sysusers u ON o.uid=u.uid
          WHERE u.name = :schema_name
              AND o.name = :table_name
              AND o.type in ('U', 'V')
        """)

        if util.py2k:
            if isinstance(schema, unicode):
                schema = schema.encode("ascii")
            if isinstance(table_name, unicode):
                table_name = table_name.encode("ascii")
        result = connection.execute(TABLEID_SQL,
                                    schema_name=schema,
                                    table_name=table_name)
        table_id = result.scalar()
        if table_id is None:
            raise exc.NoSuchTableError(table_name)
        return table_id
项目:Flask-NvRay-Blog    作者:rui7157    | 项目源码 | 文件源码
def has_table(self, connection, table_name, schema=None):
        try:
            self.get_table_id(connection, table_name, schema)
        except exc.NoSuchTableError:
            return False
        else:
            return True
项目:Flask-NvRay-Blog    作者:rui7157    | 项目源码 | 文件源码
def get_table_id(self, connection, table_name, schema=None, **kw):
        """Fetch the id for schema.table_name.

        Several reflection methods require the table id.  The idea for using
        this method is that it can be fetched one time and cached for
        subsequent calls.

        """

        table_id = None
        if schema is None:
            schema = self.default_schema_name

        TABLEID_SQL = text("""
          SELECT o.id AS id
          FROM sysobjects o JOIN sysusers u ON o.uid=u.uid
          WHERE u.name = :schema_name
              AND o.name = :table_name
              AND o.type in ('U', 'V')
        """)

        if util.py2k:
            if isinstance(schema, unicode):
                schema = schema.encode("ascii")
            if isinstance(table_name, unicode):
                table_name = table_name.encode("ascii")
        result = connection.execute(TABLEID_SQL,
                                    schema_name=schema,
                                    table_name=table_name)
        table_id = result.scalar()
        if table_id is None:
            raise exc.NoSuchTableError(table_name)
        return table_id
项目:Flask-NvRay-Blog    作者:rui7157    | 项目源码 | 文件源码
def has_table(self, connection, table_name, schema=None):
        try:
            self.get_table_id(connection, table_name, schema)
        except exc.NoSuchTableError:
            return False
        else:
            return True
项目:Callandtext    作者:iaora    | 项目源码 | 文件源码
def get_table_id(self, connection, table_name, schema=None, **kw):
        """Fetch the id for schema.table_name.

        Several reflection methods require the table id.  The idea for using
        this method is that it can be fetched one time and cached for
        subsequent calls.

        """

        table_id = None
        if schema is None:
            schema = self.default_schema_name

        TABLEID_SQL = text("""
          SELECT o.id AS id
          FROM sysobjects o JOIN sysusers u ON o.uid=u.uid
          WHERE u.name = :schema_name
              AND o.name = :table_name
              AND o.type in ('U', 'V')
        """)

        if util.py2k:
            if isinstance(schema, unicode):
                schema = schema.encode("ascii")
            if isinstance(table_name, unicode):
                table_name = table_name.encode("ascii")
        result = connection.execute(TABLEID_SQL,
                                    schema_name=schema,
                                    table_name=table_name)
        table_id = result.scalar()
        if table_id is None:
            raise exc.NoSuchTableError(table_name)
        return table_id
项目:Callandtext    作者:iaora    | 项目源码 | 文件源码
def has_table(self, connection, table_name, schema=None):
        try:
            self.get_table_id(connection, table_name, schema)
        except exc.NoSuchTableError:
            return False
        else:
            return True
项目:python_ddd_flask    作者:igorvinnicius    | 项目源码 | 文件源码
def get_table_id(self, connection, table_name, schema=None, **kw):
        """Fetch the id for schema.table_name.

        Several reflection methods require the table id.  The idea for using
        this method is that it can be fetched one time and cached for
        subsequent calls.

        """

        table_id = None
        if schema is None:
            schema = self.default_schema_name

        TABLEID_SQL = text("""
          SELECT o.id AS id
          FROM sysobjects o JOIN sysusers u ON o.uid=u.uid
          WHERE u.name = :schema_name
              AND o.name = :table_name
              AND o.type in ('U', 'V')
        """)

        if util.py2k:
            if isinstance(schema, unicode):
                schema = schema.encode("ascii")
            if isinstance(table_name, unicode):
                table_name = table_name.encode("ascii")
        result = connection.execute(TABLEID_SQL,
                                    schema_name=schema,
                                    table_name=table_name)
        table_id = result.scalar()
        if table_id is None:
            raise exc.NoSuchTableError(table_name)
        return table_id
项目:python_ddd_flask    作者:igorvinnicius    | 项目源码 | 文件源码
def has_table(self, connection, table_name, schema=None):
        try:
            self.get_table_id(connection, table_name, schema)
        except exc.NoSuchTableError:
            return False
        else:
            return True
项目:webapp    作者:superchilli    | 项目源码 | 文件源码
def get_table_id(self, connection, table_name, schema=None, **kw):
        """Fetch the id for schema.table_name.

        Several reflection methods require the table id.  The idea for using
        this method is that it can be fetched one time and cached for
        subsequent calls.

        """

        table_id = None
        if schema is None:
            schema = self.default_schema_name

        TABLEID_SQL = text("""
          SELECT o.id AS id
          FROM sysobjects o JOIN sysusers u ON o.uid=u.uid
          WHERE u.name = :schema_name
              AND o.name = :table_name
              AND o.type in ('U', 'V')
        """)

        if util.py2k:
            if isinstance(schema, unicode):
                schema = schema.encode("ascii")
            if isinstance(table_name, unicode):
                table_name = table_name.encode("ascii")
        result = connection.execute(TABLEID_SQL,
                                    schema_name=schema,
                                    table_name=table_name)
        table_id = result.scalar()
        if table_id is None:
            raise exc.NoSuchTableError(table_name)
        return table_id
项目:webapp    作者:superchilli    | 项目源码 | 文件源码
def has_table(self, connection, table_name, schema=None):
        try:
            self.get_table_id(connection, table_name, schema)
        except exc.NoSuchTableError:
            return False
        else:
            return True
项目:sqlalchemy-drill    作者:JohnOmernik    | 项目源码 | 文件源码
def has_table(self, connection, table_name, schema=None):
        try:
            self._get_table_columns(connection, table_name, schema)
            return True
        except exc.NoSuchTableError:
            return False
项目:QualquerMerdaAPI    作者:tiagovizoto    | 项目源码 | 文件源码
def get_table_id(self, connection, table_name, schema=None, **kw):
        """Fetch the id for schema.table_name.

        Several reflection methods require the table id.  The idea for using
        this method is that it can be fetched one time and cached for
        subsequent calls.

        """

        table_id = None
        if schema is None:
            schema = self.default_schema_name

        TABLEID_SQL = text("""
          SELECT o.id AS id
          FROM sysobjects o JOIN sysusers u ON o.uid=u.uid
          WHERE u.name = :schema_name
              AND o.name = :table_name
              AND o.type in ('U', 'V')
        """)

        if util.py2k:
            if isinstance(schema, unicode):
                schema = schema.encode("ascii")
            if isinstance(table_name, unicode):
                table_name = table_name.encode("ascii")
        result = connection.execute(TABLEID_SQL,
                                    schema_name=schema,
                                    table_name=table_name)
        table_id = result.scalar()
        if table_id is None:
            raise exc.NoSuchTableError(table_name)
        return table_id
项目:QualquerMerdaAPI    作者:tiagovizoto    | 项目源码 | 文件源码
def has_table(self, connection, table_name, schema=None):
        try:
            self.get_table_id(connection, table_name, schema)
        except exc.NoSuchTableError:
            return False
        else:
            return True
项目:gardenbot    作者:GoestaO    | 项目源码 | 文件源码
def get_table_id(self, connection, table_name, schema=None, **kw):
        """Fetch the id for schema.table_name.

        Several reflection methods require the table id.  The idea for using
        this method is that it can be fetched one time and cached for
        subsequent calls.

        """

        table_id = None
        if schema is None:
            schema = self.default_schema_name

        TABLEID_SQL = text("""
          SELECT o.id AS id
          FROM sysobjects o JOIN sysusers u ON o.uid=u.uid
          WHERE u.name = :schema_name
              AND o.name = :table_name
              AND o.type in ('U', 'V')
        """)

        if util.py2k:
            if isinstance(schema, unicode):
                schema = schema.encode("ascii")
            if isinstance(table_name, unicode):
                table_name = table_name.encode("ascii")
        result = connection.execute(TABLEID_SQL,
                                    schema_name=schema,
                                    table_name=table_name)
        table_id = result.scalar()
        if table_id is None:
            raise exc.NoSuchTableError(table_name)
        return table_id
项目:gardenbot    作者:GoestaO    | 项目源码 | 文件源码
def has_table(self, connection, table_name, schema=None):
        try:
            self.get_table_id(connection, table_name, schema)
        except exc.NoSuchTableError:
            return False
        else:
            return True
项目:flask-zhenai-mongo-echarts    作者:Fretice    | 项目源码 | 文件源码
def get_table_id(self, connection, table_name, schema=None, **kw):
        """Fetch the id for schema.table_name.

        Several reflection methods require the table id.  The idea for using
        this method is that it can be fetched one time and cached for
        subsequent calls.

        """

        table_id = None
        if schema is None:
            schema = self.default_schema_name

        TABLEID_SQL = text("""
          SELECT o.id AS id
          FROM sysobjects o JOIN sysusers u ON o.uid=u.uid
          WHERE u.name = :schema_name
              AND o.name = :table_name
              AND o.type in ('U', 'V')
        """)

        if util.py2k:
            if isinstance(schema, unicode):
                schema = schema.encode("ascii")
            if isinstance(table_name, unicode):
                table_name = table_name.encode("ascii")
        result = connection.execute(TABLEID_SQL,
                                    schema_name=schema,
                                    table_name=table_name)
        table_id = result.scalar()
        if table_id is None:
            raise exc.NoSuchTableError(table_name)
        return table_id
项目:flask-zhenai-mongo-echarts    作者:Fretice    | 项目源码 | 文件源码
def has_table(self, connection, table_name, schema=None):
        try:
            self.get_table_id(connection, table_name, schema)
        except exc.NoSuchTableError:
            return False
        else:
            return True
项目:pybigquery    作者:mxmzdlv    | 项目源码 | 文件源码
def _get_table(self, connection, table_name, schema=None):
        if isinstance(connection, Engine):
            connection = connection.connect()

        project, dataset, table_name_prepared = self._split_table_name(table_name)
        if dataset is None and schema is not None:
            dataset = schema
            table_name_prepared = table_name

        table = connection.connection._client.dataset(dataset, project=project).table(table_name_prepared)
        try:
            t = connection.connection._client.get_table(table)
        except NotFound as e:
            raise NoSuchTableError(table_name)
        return t
项目:pybigquery    作者:mxmzdlv    | 项目源码 | 文件源码
def has_table(self, connection, table_name, schema=None):
        try:
            self._get_table(connection, table_name, schema)
            return True
        except NoSuchTableError:
            return False
项目:pybigquery    作者:mxmzdlv    | 项目源码 | 文件源码
def test_reflect_table_does_not_exist(engine):
    with pytest.raises(NoSuchTableError):
        table = Table('test_pybigquery.table_does_not_exist', MetaData(bind=engine), autoload=True)

    assert Table('test_pybigquery.table_does_not_exist', MetaData(bind=engine)).exists() is False
项目:pybigquery    作者:mxmzdlv    | 项目源码 | 文件源码
def test_reflect_dataset_does_not_exist(engine):
    with pytest.raises(NoSuchTableError):
        Table('dataset_does_not_exist.table_does_not_exist', MetaData(bind=engine), autoload=True)
项目:Data-visualization    作者:insta-code1    | 项目源码 | 文件源码
def get_table_id(self, connection, table_name, schema=None, **kw):
        """Fetch the id for schema.table_name.

        Several reflection methods require the table id.  The idea for using
        this method is that it can be fetched one time and cached for
        subsequent calls.

        """

        table_id = None
        if schema is None:
            schema = self.default_schema_name

        TABLEID_SQL = text("""
          SELECT o.id AS id
          FROM sysobjects o JOIN sysusers u ON o.uid=u.uid
          WHERE u.name = :schema_name
              AND o.name = :table_name
              AND o.type in ('U', 'V')
        """)

        if util.py2k:
            if isinstance(schema, unicode):
                schema = schema.encode("ascii")
            if isinstance(table_name, unicode):
                table_name = table_name.encode("ascii")
        result = connection.execute(TABLEID_SQL,
                                    schema_name=schema,
                                    table_name=table_name)
        table_id = result.scalar()
        if table_id is None:
            raise exc.NoSuchTableError(table_name)
        return table_id
项目:Data-visualization    作者:insta-code1    | 项目源码 | 文件源码
def has_table(self, connection, table_name, schema=None):
        try:
            self.get_table_id(connection, table_name, schema)
        except exc.NoSuchTableError:
            return False
        else:
            return True
项目:micro-blog    作者:nickChenyx    | 项目源码 | 文件源码
def get_table_id(self, connection, table_name, schema=None, **kw):
        """Fetch the id for schema.table_name.

        Several reflection methods require the table id.  The idea for using
        this method is that it can be fetched one time and cached for
        subsequent calls.

        """

        table_id = None
        if schema is None:
            schema = self.default_schema_name

        TABLEID_SQL = text("""
          SELECT o.id AS id
          FROM sysobjects o JOIN sysusers u ON o.uid=u.uid
          WHERE u.name = :schema_name
              AND o.name = :table_name
              AND o.type in ('U', 'V')
        """)

        if util.py2k:
            if isinstance(schema, unicode):
                schema = schema.encode("ascii")
            if isinstance(table_name, unicode):
                table_name = table_name.encode("ascii")
        result = connection.execute(TABLEID_SQL,
                                    schema_name=schema,
                                    table_name=table_name)
        table_id = result.scalar()
        if table_id is None:
            raise exc.NoSuchTableError(table_name)
        return table_id
项目:micro-blog    作者:nickChenyx    | 项目源码 | 文件源码
def has_table(self, connection, table_name, schema=None):
        try:
            self.get_table_id(connection, table_name, schema)
        except exc.NoSuchTableError:
            return False
        else:
            return True
项目:python-flask-security    作者:weinbergdavid    | 项目源码 | 文件源码
def get_table_id(self, connection, table_name, schema=None, **kw):
        """Fetch the id for schema.table_name.

        Several reflection methods require the table id.  The idea for using
        this method is that it can be fetched one time and cached for
        subsequent calls.

        """

        table_id = None
        if schema is None:
            schema = self.default_schema_name

        TABLEID_SQL = text("""
          SELECT o.id AS id
          FROM sysobjects o JOIN sysusers u ON o.uid=u.uid
          WHERE u.name = :schema_name
              AND o.name = :table_name
              AND o.type in ('U', 'V')
        """)

        if util.py2k:
            if isinstance(schema, unicode):
                schema = schema.encode("ascii")
            if isinstance(table_name, unicode):
                table_name = table_name.encode("ascii")
        result = connection.execute(TABLEID_SQL,
                                    schema_name=schema,
                                    table_name=table_name)
        table_id = result.scalar()
        if table_id is None:
            raise exc.NoSuchTableError(table_name)
        return table_id
项目:python-flask-security    作者:weinbergdavid    | 项目源码 | 文件源码
def has_table(self, connection, table_name, schema=None):
        try:
            self.get_table_id(connection, table_name, schema)
        except exc.NoSuchTableError:
            return False
        else:
            return True
项目:watcher    作者:nosmokingbandit    | 项目源码 | 文件源码
def get_table_id(self, connection, table_name, schema=None, **kw):
        """Fetch the id for schema.table_name.

        Several reflection methods require the table id.  The idea for using
        this method is that it can be fetched one time and cached for
        subsequent calls.

        """

        table_id = None
        if schema is None:
            schema = self.default_schema_name

        TABLEID_SQL = text("""
          SELECT o.id AS id
          FROM sysobjects o JOIN sysusers u ON o.uid=u.uid
          WHERE u.name = :schema_name
              AND o.name = :table_name
              AND o.type in ('U', 'V')
        """)

        if util.py2k:
            if isinstance(schema, unicode):
                schema = schema.encode("ascii")
            if isinstance(table_name, unicode):
                table_name = table_name.encode("ascii")
        result = connection.execute(TABLEID_SQL,
                                    schema_name=schema,
                                    table_name=table_name)
        table_id = result.scalar()
        if table_id is None:
            raise exc.NoSuchTableError(table_name)
        return table_id
项目:watcher    作者:nosmokingbandit    | 项目源码 | 文件源码
def has_table(self, connection, table_name, schema=None):
        try:
            self.get_table_id(connection, table_name, schema)
        except exc.NoSuchTableError:
            return False
        else:
            return True
项目:Lixiang_zhaoxin    作者:hejaxian    | 项目源码 | 文件源码
def get_table_id(self, connection, table_name, schema=None, **kw):
        """Fetch the id for schema.table_name.

        Several reflection methods require the table id.  The idea for using
        this method is that it can be fetched one time and cached for
        subsequent calls.

        """

        table_id = None
        if schema is None:
            schema = self.default_schema_name

        TABLEID_SQL = text("""
          SELECT o.id AS id
          FROM sysobjects o JOIN sysusers u ON o.uid=u.uid
          WHERE u.name = :schema_name
              AND o.name = :table_name
              AND o.type in ('U', 'V')
        """)

        if util.py2k:
            if isinstance(schema, unicode):
                schema = schema.encode("ascii")
            if isinstance(table_name, unicode):
                table_name = table_name.encode("ascii")
        result = connection.execute(TABLEID_SQL,
                                    schema_name=schema,
                                    table_name=table_name)
        table_id = result.scalar()
        if table_id is None:
            raise exc.NoSuchTableError(table_name)
        return table_id
项目:Lixiang_zhaoxin    作者:hejaxian    | 项目源码 | 文件源码
def has_table(self, connection, table_name, schema=None):
        try:
            self.get_table_id(connection, table_name, schema)
        except exc.NoSuchTableError:
            return False
        else:
            return True
项目:flask    作者:bobohope    | 项目源码 | 文件源码
def get_table_id(self, connection, table_name, schema=None, **kw):
        """Fetch the id for schema.table_name.

        Several reflection methods require the table id.  The idea for using
        this method is that it can be fetched one time and cached for
        subsequent calls.

        """

        table_id = None
        if schema is None:
            schema = self.default_schema_name

        TABLEID_SQL = text("""
          SELECT o.id AS id
          FROM sysobjects o JOIN sysusers u ON o.uid=u.uid
          WHERE u.name = :schema_name
              AND o.name = :table_name
              AND o.type in ('U', 'V')
        """)

        if util.py2k:
            if isinstance(schema, unicode):
                schema = schema.encode("ascii")
            if isinstance(table_name, unicode):
                table_name = table_name.encode("ascii")
        result = connection.execute(TABLEID_SQL,
                                    schema_name=schema,
                                    table_name=table_name)
        table_id = result.scalar()
        if table_id is None:
            raise exc.NoSuchTableError(table_name)
        return table_id