Skip to main content

A memory-level non-relational database

Project description

apm

介绍

jsonDB2是一个基于内存的键值对数据库(非关系型数据库)

安装

$ pip install jdb2

或者

$ git clone https://github.com/spdir/jsonDB2.git
$ cd jsonDB2
$ python setup.py install

使用

  1. 初始化实例
import jdb2
#初始化一个空的DB
n = jdb2.NoSql()
#将原来的数据导入到数据库,并配置自动持久化
n = jdb2.NoSql(dump=True, nosqlFile='filePath', dumpTime=10)
  # dump: 启动持久化,并导入已有数据, 默认: False
  # nosqlFile: 持久化文件路径
  # dumpTime: 持久化时间间隔(单位: 秒), 默认: 30
#创建一个数据库, 如果数据库存在此库,则返回存在库的对象
d1 = n.createDB('d1')
  1. 操作使用
>>> import jdb2
>>> n = jdb2.NoSql()   #初始化实例对象
>>> d1 = n.createDB('d1') #创建一个DB
>>> t1 = d1.createTable('t1') #创建一张表
>>> d1.setValue('a','b')  #db设置一个参数
>>> d1.getValue('a')  #db获取一个参数
'b'
>>> t1.setValue(1,2)  #tb设置一个参数
>>> t1.getValue(1)  #tb获取一个参数
2
>>> d1.getValues()  #获取所有的value
[{1: 2}, 'b']
>>> d1.getKeys()  #获取所有的key
['t1', 'a']
>>> d1.getItems() #获取所有的键值对, 返回list
[('t1', {1: 2}), ('a', 'b')]
>>> d1.dropKey('a') #删除一个键或者一张表
>>> d1.setValue('c','d')
>>> d1.clearKey('c')  #清除一个key的内容
>>> d1.getItems()
[('t1', {1: 2}), ('c', None)]
>>> d1.clearKey('t1') #清除一张表的内容
>>> d1.getItems()
[('t1', {}), ('c', None)]
>>> t1.lenTable() #获取数据库或表长度
1
>>> d1.allData()  #获取所有的表或库的所有键值对,返回dict
{'t1': {}, 'c': None}

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

jdb2-0.2.2.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

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

jdb2-0.2.2-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file jdb2-0.2.2.tar.gz.

File metadata

  • Download URL: jdb2-0.2.2.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0

File hashes

Hashes for jdb2-0.2.2.tar.gz
Algorithm Hash digest
SHA256 00a3098559c637a3f3d9a804cc0b345e331cc21e6d15b32d66b3b47c225488b5
MD5 f33589b823b8cfb4aa9db9b09cfd3484
BLAKE2b-256 0debf9ef53555dbc2ac6b3968c20fbb07c6f844caf89964d092d75b6d2d0b3b1

See more details on using hashes here.

File details

Details for the file jdb2-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: jdb2-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0

File hashes

Hashes for jdb2-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 af7d924db73e4bd49d664e501d3b11ac5b3950bc17f32d8d32ee22632243ac93
MD5 86f45bba1cd79570fd80e1b9d7636957
BLAKE2b-256 786b013e2090623264de86b9bbe8637524dd8576853fc2b5dfa318803bebb6dc

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