mongo.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:database_assetstore 作者: OpenGeoscience 项目源码 文件源码
def getTableList(uri, internalTables=False, **kwargs):
        """
        Get a list of known databases, each of which has a list of known
        collections from the database.  This is of the form [{'database':
        (database 1), 'tables': [{'table': (collection 1)}, {'table':
        (collection 2)}, ...]}, {'database': (database 2), 'tables': [...]},
        ...]

        :param uri: uri to connect to the database.
        :param internaltables: True to return tables about the database itself.
            Ignored for Mongo.
        :returns: A list of known collections.
        """
        conn = MongoClient(uri)
        databaseName = base.databaseFromUri(uri)
        if databaseName is None:
            databaseNames = conn.database_names()
        else:
            databaseNames = [databaseName]
        results = []
        for name in databaseNames:
            database = conn[name]
            results.append({
                'database': name,
                'tables': [{'table': collection, 'name': collection}
                           for collection in database.collection_names(False)]
            })
        return results
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号