A Simple Time Series Database Implemented By Python Library.
Project description
tslite
A Simple Time Series Database Implemented By Python Library.
Install
pip install tslite
Usage
# -*- coding: UTF-8 -*
'''
Created on 2020-02-19
'''
from __future__ import print_function
import random, time
import tslite
path = '/tmp/tsdb/test' # the database path
db = tslite.Database(path)
tabname = 't1'
db.drop_table(tabname) # clern table
# get table
tab = db.get_table(tabname)
# define the table struct
tab.define({
'field_lock': True, # lock the table struct
'fields': [
{'name': 'name', 'type': 'string', 'index': True},
{'name': 'group', 'type': 'int', 'index': True},
{'name': 'x', 'type': 'int', 'index': True},
{'name': 'v', 'type': 'int'},
{'name': 'y', 'type': 'float'},
{'name': 'z', 'type': 'float'},
{'name': 't', 'type': 'float'},
]
})
# count for testing
count = 10
tm = time.time()
for i in range(count):
# write data
tab.write_data({'x': i, 'time': tm + i, 'name': random.choice(['a', 'aa', 'bb']), 'y': random.random()})
# query data
q = tab.query()
for r in q:
print(r)
print('name is "a":')
# query field 'name' == "a"
q = tab.query(eqs={'name': 'a'})
for r in q:
print(r)
Click to view more information!
CHANGES
1.0.0
- first version
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tslite-1.0.2.tar.gz
(5.4 kB
view details)
File details
Details for the file tslite-1.0.2.tar.gz
.
File metadata
- Download URL: tslite-1.0.2.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1fc096e879a57ba4cc32fef16e4a0819fb77c9f61fcef93445f7ad1485c8216 |
|
MD5 | 0b604139b39a72ee5672a62893e8c6a7 |
|
BLAKE2b-256 | e1d467cc6b7b5be1a94ca8db4057e5e61b8e963d0a045c989b677c7f0017e710 |