Skip to main content

No project description provided

Project description

UserConf

本项目在TinyDB基础上,做了一些调整,具体如下:

  • 修改class JSONStorage(Storage), 取消默认 ASCII 编码
  • 最后重新打包(fhtinydb);

Quick Links

Introduction

TinyDB is a lightweight document oriented database optimized for your happiness :) It's written in pure Python and has no external dependencies. The target are small apps that would be blown away by a SQL-DB or an external database server.

TinyDB is:

  • tiny: The current source code has 1800 lines of code (with about 40% documentation) and 1600 lines tests.

  • document oriented: Like MongoDB, you can store any document (represented as dict) in TinyDB.

  • optimized for your happiness: TinyDB is designed to be simple and fun to use by providing a simple and clean API.

  • written in pure Python: TinyDB neither needs an external server (as e.g. PyMongo) nor any dependencies from PyPI.

  • works on Python 3.8+ and PyPy3: TinyDB works on all modern versions of Python and PyPy.

  • powerfully extensible: You can easily extend TinyDB by writing new storages or modify the behaviour of storages with Middlewares.

  • 100% test coverage: No explanation needed.

To dive straight into all the details, head over to the TinyDB docs . You can also discuss everything related to TinyDB like general development, extensions or showcase your TinyDB-based projects on the discussion forum.

Supported Python Versions

TinyDB has been tested with Python 3.8 - 3.13 and PyPy3.

Project Status

This project is in maintenance mode. It has reached a mature, stable state where significant new features or architectural changes are not planned. That said, there will still be releases for bugfixes or features contributed by the community. Read more about what this means in particular here.

Example Code

    >>> from tinydb import TinyDB, Query
    >>> db = TinyDB('/path/to/db.json')
    >>> db.insert({'int': 1, 'char': 'a'})
    >>> db.insert({'int': 1, 'char': 'b'})

Query Language

    >>> User = Query()
    >>> # Search for a field value
    >>> db.search(User.name == 'John')
    [{'name': 'John', 'age': 22}, {'name': 'John', 'age': 37}]

    >>> # Combine two queries with logical and
    >>> db.search((User.name == 'John') & (User.age <= 30))
    [{'name': 'John', 'age': 22}]

    >>> # Combine two queries with logical or
    >>> db.search((User.name == 'John') | (User.name == 'Bob'))
    [{'name': 'John', 'age': 22}, {'name': 'John', 'age': 37}, {'name': 'Bob', 'age': 42}]

    >>> # Negate a query with logical not
    >>> db.search(~(User.name == 'John'))
    [{'name': 'Megan', 'age': 27}, {'name': 'Bob', 'age': 42}]

    >>> # Apply transformation to field with `map`
    >>> db.search((User.age.map(lambda x: x + x) == 44))
    >>> [{'name': 'John', 'age': 22}]

    >>> # More possible comparisons:  !=  <  >  <=  >=
    >>> # More possible checks: where(...).matches(regex), where(...).test(your_test_func)

Tables

    >>> table = db.table('name')
    >>> table.insert({'value': True})
    >>> table.all()
    [{'value': True}]

Using Middlewares

    >>> from tinydb.storages import JSONStorage
    >>> from tinydb.middlewares import CachingMiddleware
    >>> db = TinyDB('/path/to/db.json', storage=CachingMiddleware(JSONStorage))

Contributing

Whether reporting bugs, discussing improvements and new ideas or writing extensions: Contributions to TinyDB are welcome! Here's how to get started:

  1. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug
  2. Fork the repository <https://github.com/msiemens/tinydb/>_ on Github, create a new branch off the master branch and start making your changes (known as GitHub Flow <https://guides.github.com/introduction/flow/index.html>_)
  3. Write a test which shows that the bug was fixed or that the feature works as expected
  4. Send a pull request and bug the maintainer until it gets merged and published ☺

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fhtinydb-0.1.1.tar.gz (20.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fhtinydb-0.1.1-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

Details for the file fhtinydb-0.1.1.tar.gz.

File metadata

  • Download URL: fhtinydb-0.1.1.tar.gz
  • Upload date:
  • Size: 20.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.8.10 Windows/10

File hashes

Hashes for fhtinydb-0.1.1.tar.gz
Algorithm Hash digest
SHA256 77d6c845c96fc6f1aa2629c3e1d2fb3cea9234b7bbace9628edc46c7a52979d5
MD5 cd0643a680ba03266fda938e87323091
BLAKE2b-256 dae1714f663be2950ffafcd0716a13af9373ea09be36667323290bb75d1c5508

See more details on using hashes here.

File details

Details for the file fhtinydb-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: fhtinydb-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 23.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.8.10 Windows/10

File hashes

Hashes for fhtinydb-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6c699ddd7965c0acafa063cacd0e4bef4fb1615cf59e1c5aecb22ab845f4aa03
MD5 49ebbedb35148362fb55e169ed58bde5
BLAKE2b-256 5c9f7f2faebcb1d115735bc44e9de65716422bb8254361a63e4da8e455bdca7b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page