Skip to main content

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}

Release files for jdb2 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jdb2 0.2.2
File Size Uploaded
jdb2-0.2.2.tar.gz 4.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jdb2 0.2.2
File Interpreter ABI Platform
jdb2-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 9.4 kB

Release files / jdb2-0.2.2.tar.gz

Download URL jdb2-0.2.2.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
00a3098559c637a3f3d9a804cc0b345e331cc21e6d15b32d66b3b47c225488b5
BLAKE2b-256 checksum
How to use checksums
0debf9ef53555dbc2ac6b3968c20fbb07c6f844caf89964d092d75b6d2d0b3b1
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / jdb2-0.2.2-py3-none-any.whl

Download URL jdb2-0.2.2-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
af7d924db73e4bd49d664e501d3b11ac5b3950bc17f32d8d32ee22632243ac93
BLAKE2b-256 checksum
How to use checksums
786b013e2090623264de86b9bbe8637524dd8576853fc2b5dfa318803bebb6dc
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page