伪NoSQL数据库

rundb的Python项目详细描述


运行数据库

RunDb并不完全是一个数据库。它类似于 TinyDB <https://tinydb.readthedocs.io/en/stable/>\ 作为json。在

这个库的主要功能是帮助用户存储和 正在加载数据。在

哲学

  • NoSql与模拟关系的工具
  • 表在声明时都已完全加载
  • 查询是使用python完成的
  • 数据是dict,它们都有一个唯一的键作为字符串

快速概述


.. code:: python

    import RunDB
    from pathlib import Path
    from RunDB.tools.serialization import call_kwargs

    # Path to DB folder
    db_path = Path("testRunDB")
    # Create the Database instance
    db = RunDB.Database(db_path)

    # Get or Create User table, specifying the key as login (default is "id")
    # The key is used to find, if not explicitly given, the database id
    User = db.table("user", key="login")

    # Same for Group table
    Group = db.table(
        "group",
        key="name",
        one2many={"users": "user"}
    )

    # Create User 1
    u1 = User.append({"login": "paul"})  # With values

    # without values, 
    u2 = User["Matthieu"]
    u3 = User["Thomas"]

    u1.age = 18
    u2.age = 20
    u3.age = 18

    res = User.filter(lambda user: user.age == 20)

    list(User.records())


    test= Group["test"]
    test.users.append(u1)


    adminGroup = Group.append({
        "name": "admin",  # as the table key is "name", name will be poped
    })


    db["test"]["new"] = {"name": "new data"}  # Quick insert

    # Check if record has attribute age
    "age" in u1  # True

    # Get a dict
    data = dict(u1.items())

    db.dump_all()

Nb: Database are simply Group of Table, We can register Tables from
somewhere else or simply use a Table without Database object

Future
------

-  improve relational

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
分别使用椭圆曲线密码对文本消息进行java加密和解密   java如何将JTable滚动到特定值?   java JSP登录注销简单web应用程序,使用bean在数据库中存在数据时返回false   java无法编译,未设置类路径,包不存在?   java为什么这一变量会受到影响?   集合为什么Java在Map中没有putIfAbsent(key,supplier)方法?   安卓在Java中计算仿真时间   java初始化方法在主类中的指定方法之前运行   java如何在hadoop的reduce中将genericWritable恢复为用户定义的可写?   如何使用java替换pdf中的文本   参数不适用于ASP服务器的java HttpPost   创建对象时的java NullPointerException   Java JPanel中的swing图形有问题,但它在一个框架中工作   java Android Studio在硬件设备上运行时出错   google api类路径的java空指针异常   java如何将InputStream转换为DataHandler?   java在多个Jetty服务器之间共享连接池