ConfigByLmdb


NameConfigByLmdb JSON
Version 0.0.10 PyPI version JSON
download
home_pagehttps://github.com/jnwatson/py-lmdb/
Summarylmdb 自定义封装
upload_time2024-07-28 08:35:42
maintainerNone
docs_urlNone
authorCC
requires_python>=3
licenseThe OpenLDAP Public License Version 2.8, 17 August 2003 Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions in source form must retain copyright statements and notices, 2. Redistributions in binary form must reproduce applicable copyright statements and notices, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution, 3. Redistributions must contain a verbatim copy of this document. The OpenLDAP Foundation may revise this license from time to time. Each revision is distinguished by a version number. You may use this Software under terms of this license revision or under the terms of any subsequent revision of the license. THIS SOFTWARE IS PROVIDED BY THE OPENLDAP FOUNDATION AND ITS CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENLDAP FOUNDATION, ITS CONTRIBUTORS, OR THE AUTHOR(S) OR OWNER(S) OF THE SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The names of the authors and copyright holders must not be used in advertising or otherwise to promote the sale, use or other dealing in this Software without specific, written prior permission. Title to copyright in this Software shall at all times remain with copyright holders. OpenLDAP is a registered trademark of the OpenLDAP Foundation. Copyright 1999-2003 The OpenLDAP Foundation, Redwood City, California, USA. All Rights Reserved. Permission to copy and distribute verbatim copies of this document is granted.
keywords configbylmdb configdb lmdb
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            =============
ConfigByLmdb
=============

ConfigByLmdb 是一个基于 lmdb 1.5.1 版本 自定义封装的库,主要用于快速动态读写大量配置信息的数据库工具。

概述
----

lmdb是一个轻量级、本地部署的高性能数据库,ConfigByLmdb 仅对其进行了某些场景简单的接口封装。


安装
----

使用 pip 安装 ConfigByLmdb :

.. code-block:: bash

    pip install ConfigByLmdb

请注意,由于本项目是 lmdb 的自定义封装版本,可能需要从源代码安装或使用特定的安装步骤。

使用示例
--------

以下是一个简单的使用示例,展示如何使用:

.. code-block:: python

    from ConfigByLmdb import DB,Structure

    db = DB()
    
    db_name = 'db'
    name_db = 'test'

    # 创建或初始化数据库
    print(db.init_db(db_name))

    # 创建命名数据库
    # data = Structure("主键名",[('a',str),('b',str),('c',dict),('d',int),("e",float)]) # 设置数据库结构
    # print(db.create_name_db(db_name,name_db,"这是一个测试命名数据库",data))

    # 添加
    # print(db.write(db_name,name_db,'t1',{'a':"你好",'b':"123",'c':{"f":1,"g":'abc'},"d":189,"e":0.123}))
    # print(db.write(db_name,name_db,'t2',{'a':"hello!",'b':"234",'c':{"f":3,"g":'ret'},"d":49,"e":15.48}))
    # print(db.write(db_name,name_db,'t3',{'a':"A和B",'b':"858",'c':{"f":3,"g":'ret'},"d":49,"e":15.48}))
    # print(db.write(db_name,name_db,json.dumps({'a':"A和B",'b':858}),{'a':"A和B",'b':858}))
    # 错误示范(数据格式不对应)
    # l = []
    # for i in range(10):
    #     l.append({'body'+str(i):{'a':"你好",'b':"318",'c':None,"d":4945,"e":185.48}})
    # print(db.batch_write(db_name,name_db,l))
    # 正确示范
    # l = []
    # import random
    # for i in range(1000):
    #     l.append({'body'+str(i):"a"+str(i * random.randint(1, 100))})
    # print(db.batch_write(db_name,name_db,l))
    # print(db.get_sum(db_name,name_db))

    # 查询
    # print(db.read(db_name,name_db,'body2'))
    # print(db.get(db_name,name_db,['body4','c','f']))
    # print(db.get_limit(db_name,name_db,0,100))
    # 匹配查询
    # print(db.matching(db_name,name_db,"body1",0,10),len(db.matching(db_name,name_db,"body1",0,10)[0]))
    # print(db.matching(db_name,name_db,"修改后的值",0,10),len(db.matching(db_name,name_db,"修改后的值",0,10)[0]))
    # print(db.matching(db_name,name_db,45,matching_level=-2))
    # print(db.precise_matching(db_name,name_db,str({'a':"A和B",'b':858}),matching_level=-2))
    # print(db.precise_matching(db_name,name_db,json.dumps({'a':"A和B",'b':858}),matching_level=0))

    # 删除
    # print(db.read(db_name,name_db,'body5'))
    # print(db.remove(db_name,name_db,['body5','c','f']))
    # print(db.read(db_name,name_db,'body5'))
    # print(db.delete(db_name,name_db,json.dumps({'a':"A和B",'b':858})))
    # print(db.read(db_name,name_db,json.dumps({'a':"A和B",'b':858})))

    # 修改
    # print(db.read(db_name,name_db,'body3'))
    # print(db.updata(db_name,name_db,"body3",{'a':"修改后的值",'b':"315",'c':{"t":1},"d":911,"e":1.48}))
    # print(db.read(db_name,name_db,'body3'))
    # print(db.read(db_name,name_db,'body6'))
    # print(db.set(db_name,name_db,['body6','a'],"修改后的值"))
    # print(db.read(db_name,name_db,'body6'))

    # 数据库信息
    # print(db.get_sum(db_name,name_db))
    # print(db.get_name_database_list(db_name)) # 指定数据库下命名数据库列表
    # print(db.get_db_name_list()) # 所有数据库列表
    # print(db.get_db_info(db_name)) # 数据库配置信息

    # 数据库操作
    # print(db.drop_name_db(db_name,name_db)) # 删除指定命名数据库
    # print(db.get_name_database_list(db_name))
    # print(db.env_close(db_name)) # 关闭指定数据库
    # print(db.cleanup(db_name)) # 删除指定数据库
    # print(db.get_db_name_list())

    ########################################################
    # web访问
    from ConfigByLmdb.web import run
    run()
    # 打开浏览器访问
    # http://127.0.0.1:8080/

贡献
----

我们欢迎任何形式的贡献,包括但不限于:

- 报告问题或错误。
- 提供功能请求或改进建议。

许可证
------

本项目采用 OLDAP-2.8 许可证。有关更多信息,请查看 `LICENSE` 文件。

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jnwatson/py-lmdb/",
    "name": "ConfigByLmdb",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3",
    "maintainer_email": null,
    "keywords": "ConfigByLmdb, ConfigDB, lmdb",
    "author": "CC",
    "author_email": "3204604858@qq.com",
    "download_url": "https://files.pythonhosted.org/packages/14/61/861ab55a424af4dcb978d657b4853d28ed5408b183327cbbd5e1711c954e/configbylmdb-0.0.10.tar.gz",
    "platform": "Windows",
    "description": "=============\r\nConfigByLmdb\r\n=============\r\n\r\nConfigByLmdb \u662f\u4e00\u4e2a\u57fa\u4e8e lmdb 1.5.1 \u7248\u672c \u81ea\u5b9a\u4e49\u5c01\u88c5\u7684\u5e93\uff0c\u4e3b\u8981\u7528\u4e8e\u5feb\u901f\u52a8\u6001\u8bfb\u5199\u5927\u91cf\u914d\u7f6e\u4fe1\u606f\u7684\u6570\u636e\u5e93\u5de5\u5177\u3002\r\n\r\n\u6982\u8ff0\r\n----\r\n\r\nlmdb\u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u3001\u672c\u5730\u90e8\u7f72\u7684\u9ad8\u6027\u80fd\u6570\u636e\u5e93\uff0cConfigByLmdb \u4ec5\u5bf9\u5176\u8fdb\u884c\u4e86\u67d0\u4e9b\u573a\u666f\u7b80\u5355\u7684\u63a5\u53e3\u5c01\u88c5\u3002\r\n\r\n\r\n\u5b89\u88c5\r\n----\r\n\r\n\u4f7f\u7528 pip \u5b89\u88c5 ConfigByLmdb \uff1a\r\n\r\n.. code-block:: bash\r\n\r\n    pip install ConfigByLmdb\r\n\r\n\u8bf7\u6ce8\u610f\uff0c\u7531\u4e8e\u672c\u9879\u76ee\u662f lmdb \u7684\u81ea\u5b9a\u4e49\u5c01\u88c5\u7248\u672c\uff0c\u53ef\u80fd\u9700\u8981\u4ece\u6e90\u4ee3\u7801\u5b89\u88c5\u6216\u4f7f\u7528\u7279\u5b9a\u7684\u5b89\u88c5\u6b65\u9aa4\u3002\r\n\r\n\u4f7f\u7528\u793a\u4f8b\r\n--------\r\n\r\n\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f7f\u7528\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u4f7f\u7528\uff1a\r\n\r\n.. code-block:: python\r\n\r\n    from ConfigByLmdb import DB,Structure\r\n\r\n    db = DB()\r\n    \r\n    db_name = 'db'\r\n    name_db = 'test'\r\n\r\n    # \u521b\u5efa\u6216\u521d\u59cb\u5316\u6570\u636e\u5e93\r\n    print(db.init_db(db_name))\r\n\r\n    # \u521b\u5efa\u547d\u540d\u6570\u636e\u5e93\r\n    # data = Structure(\"\u4e3b\u952e\u540d\",[('a',str),('b',str),('c',dict),('d',int),(\"e\",float)]) # \u8bbe\u7f6e\u6570\u636e\u5e93\u7ed3\u6784\r\n    # print(db.create_name_db(db_name,name_db,\"\u8fd9\u662f\u4e00\u4e2a\u6d4b\u8bd5\u547d\u540d\u6570\u636e\u5e93\",data))\r\n\r\n    # \u6dfb\u52a0\r\n    # print(db.write(db_name,name_db,'t1',{'a':\"\u4f60\u597d\",'b':\"123\",'c':{\"f\":1,\"g\":'abc'},\"d\":189,\"e\":0.123}))\r\n    # print(db.write(db_name,name_db,'t2',{'a':\"hello!\",'b':\"234\",'c':{\"f\":3,\"g\":'ret'},\"d\":49,\"e\":15.48}))\r\n    # print(db.write(db_name,name_db,'t3',{'a':\"A\u548cB\",'b':\"858\",'c':{\"f\":3,\"g\":'ret'},\"d\":49,\"e\":15.48}))\r\n    # print(db.write(db_name,name_db,json.dumps({'a':\"A\u548cB\",'b':858}),{'a':\"A\u548cB\",'b':858}))\r\n    # \u9519\u8bef\u793a\u8303(\u6570\u636e\u683c\u5f0f\u4e0d\u5bf9\u5e94)\r\n    # l = []\r\n    # for i in range(10):\r\n    #     l.append({'body'+str(i):{'a':\"\u4f60\u597d\",'b':\"318\",'c':None,\"d\":4945,\"e\":185.48}})\r\n    # print(db.batch_write(db_name,name_db,l))\r\n    # \u6b63\u786e\u793a\u8303\r\n    # l = []\r\n    # import random\r\n    # for i in range(1000):\r\n    #     l.append({'body'+str(i):\"a\"+str(i * random.randint(1, 100))})\r\n    # print(db.batch_write(db_name,name_db,l))\r\n    # print(db.get_sum(db_name,name_db))\r\n\r\n    # \u67e5\u8be2\r\n    # print(db.read(db_name,name_db,'body2'))\r\n    # print(db.get(db_name,name_db,['body4','c','f']))\r\n    # print(db.get_limit(db_name,name_db,0,100))\r\n    # \u5339\u914d\u67e5\u8be2\r\n    # print(db.matching(db_name,name_db,\"body1\",0,10),len(db.matching(db_name,name_db,\"body1\",0,10)[0]))\r\n    # print(db.matching(db_name,name_db,\"\u4fee\u6539\u540e\u7684\u503c\",0,10),len(db.matching(db_name,name_db,\"\u4fee\u6539\u540e\u7684\u503c\",0,10)[0]))\r\n    # print(db.matching(db_name,name_db,45,matching_level=-2))\r\n    # print(db.precise_matching(db_name,name_db,str({'a':\"A\u548cB\",'b':858}),matching_level=-2))\r\n    # print(db.precise_matching(db_name,name_db,json.dumps({'a':\"A\u548cB\",'b':858}),matching_level=0))\r\n\r\n    # \u5220\u9664\r\n    # print(db.read(db_name,name_db,'body5'))\r\n    # print(db.remove(db_name,name_db,['body5','c','f']))\r\n    # print(db.read(db_name,name_db,'body5'))\r\n    # print(db.delete(db_name,name_db,json.dumps({'a':\"A\u548cB\",'b':858})))\r\n    # print(db.read(db_name,name_db,json.dumps({'a':\"A\u548cB\",'b':858})))\r\n\r\n    # \u4fee\u6539\r\n    # print(db.read(db_name,name_db,'body3'))\r\n    # print(db.updata(db_name,name_db,\"body3\",{'a':\"\u4fee\u6539\u540e\u7684\u503c\",'b':\"315\",'c':{\"t\":1},\"d\":911,\"e\":1.48}))\r\n    # print(db.read(db_name,name_db,'body3'))\r\n    # print(db.read(db_name,name_db,'body6'))\r\n    # print(db.set(db_name,name_db,['body6','a'],\"\u4fee\u6539\u540e\u7684\u503c\"))\r\n    # print(db.read(db_name,name_db,'body6'))\r\n\r\n    # \u6570\u636e\u5e93\u4fe1\u606f\r\n    # print(db.get_sum(db_name,name_db))\r\n    # print(db.get_name_database_list(db_name)) # \u6307\u5b9a\u6570\u636e\u5e93\u4e0b\u547d\u540d\u6570\u636e\u5e93\u5217\u8868\r\n    # print(db.get_db_name_list()) # \u6240\u6709\u6570\u636e\u5e93\u5217\u8868\r\n    # print(db.get_db_info(db_name)) # \u6570\u636e\u5e93\u914d\u7f6e\u4fe1\u606f\r\n\r\n    # \u6570\u636e\u5e93\u64cd\u4f5c\r\n    # print(db.drop_name_db(db_name,name_db)) # \u5220\u9664\u6307\u5b9a\u547d\u540d\u6570\u636e\u5e93\r\n    # print(db.get_name_database_list(db_name))\r\n    # print(db.env_close(db_name)) # \u5173\u95ed\u6307\u5b9a\u6570\u636e\u5e93\r\n    # print(db.cleanup(db_name)) # \u5220\u9664\u6307\u5b9a\u6570\u636e\u5e93\r\n    # print(db.get_db_name_list())\r\n\r\n    ########################################################\r\n    # web\u8bbf\u95ee\r\n    from ConfigByLmdb.web import run\r\n    run()\r\n    # \u6253\u5f00\u6d4f\u89c8\u5668\u8bbf\u95ee\r\n    # http://127.0.0.1:8080/\r\n\r\n\u8d21\u732e\r\n----\r\n\r\n\u6211\u4eec\u6b22\u8fce\u4efb\u4f55\u5f62\u5f0f\u7684\u8d21\u732e\uff0c\u5305\u62ec\u4f46\u4e0d\u9650\u4e8e\uff1a\r\n\r\n- \u62a5\u544a\u95ee\u9898\u6216\u9519\u8bef\u3002\r\n- \u63d0\u4f9b\u529f\u80fd\u8bf7\u6c42\u6216\u6539\u8fdb\u5efa\u8bae\u3002\r\n\r\n\u8bb8\u53ef\u8bc1\r\n------\r\n\r\n\u672c\u9879\u76ee\u91c7\u7528 OLDAP-2.8 \u8bb8\u53ef\u8bc1\u3002\u6709\u5173\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u67e5\u770b `LICENSE` \u6587\u4ef6\u3002\r\n",
    "bugtrack_url": null,
    "license": "The OpenLDAP Public License Version 2.8, 17 August 2003  Redistribution and use of this software and associated documentation (\"Software\"), with or without modification, are permitted provided that the following conditions are met:  1. Redistributions in source form must retain copyright statements and notices,  2. Redistributions in binary form must reproduce applicable copyright statements and notices, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution,  3. Redistributions must contain a verbatim copy of this document.  The OpenLDAP Foundation may revise this license from time to time. Each revision is distinguished by a version number.  You may use this Software under terms of this license revision or under the terms of any subsequent revision of the license.  THIS SOFTWARE IS PROVIDED BY THE OPENLDAP FOUNDATION AND ITS CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OPENLDAP FOUNDATION, ITS CONTRIBUTORS, OR THE AUTHOR(S) OR OWNER(S) OF THE SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  The names of the authors and copyright holders must not be used in advertising or otherwise to promote the sale, use or other dealing in this Software without specific, written prior permission.  Title to copyright in this Software shall at all times remain with copyright holders.  OpenLDAP is a registered trademark of the OpenLDAP Foundation.  Copyright 1999-2003 The OpenLDAP Foundation, Redwood City, California, USA.  All Rights Reserved.  Permission to copy and distribute verbatim copies of this document is granted.",
    "summary": "lmdb \u81ea\u5b9a\u4e49\u5c01\u88c5",
    "version": "0.0.10",
    "project_urls": {
        "Homepage": "https://github.com/jnwatson/py-lmdb/"
    },
    "split_keywords": [
        "configbylmdb",
        " configdb",
        " lmdb"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e97ff74551d102239a49f85d90e72d384ee9145b482f4f0072aaf790e9e7eae1",
                "md5": "64e2b1a89783c66dd5577beeae6d2c60",
                "sha256": "9a3d627f517ed3be1b454ab5d2f70549e25782eed5e32961474fb9ad5f34060f"
            },
            "downloads": -1,
            "filename": "ConfigByLmdb-0.0.10-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "64e2b1a89783c66dd5577beeae6d2c60",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3",
            "size": 21210,
            "upload_time": "2024-07-28T08:35:39",
            "upload_time_iso_8601": "2024-07-28T08:35:39.896603Z",
            "url": "https://files.pythonhosted.org/packages/e9/7f/f74551d102239a49f85d90e72d384ee9145b482f4f0072aaf790e9e7eae1/ConfigByLmdb-0.0.10-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1461861ab55a424af4dcb978d657b4853d28ed5408b183327cbbd5e1711c954e",
                "md5": "bc59abdbd101b6381772fa82bdfaa12e",
                "sha256": "7c2713a43b52308d4b5157a94078b3e3414b441f4c89368ec21f3247ebf5e32d"
            },
            "downloads": -1,
            "filename": "configbylmdb-0.0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "bc59abdbd101b6381772fa82bdfaa12e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3",
            "size": 19037,
            "upload_time": "2024-07-28T08:35:42",
            "upload_time_iso_8601": "2024-07-28T08:35:42.281307Z",
            "url": "https://files.pythonhosted.org/packages/14/61/861ab55a424af4dcb978d657b4853d28ed5408b183327cbbd5e1711c954e/configbylmdb-0.0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-28 08:35:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jnwatson",
    "github_project": "py-lmdb",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "configbylmdb"
}
        
CC
Elapsed time: 0.31734s