1 Star 0 Fork 0

康帅/crown

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
README_EN.rst 2.17 KB
一键复制 编辑 原始数据 按行查看 历史
ma2ma 提交于 2020-11-29 12:44 . add english readme

crown

crown is a simple and small ORM forTDengine(TSDB)

  • python 3.0 up
  • tdengine 2.0.8 up

Installing

Most users will want to simply install the latest version, hosted on PyPI:

pip install crown

The project is hosted at https://github.com/machine-w/crown and can be installed using git:

git clone https://github.com/machine-w/crown.git
cd crowm
python setup.py install

Quickstart

Model Definition:

from crown import *
import datetime


DATABASENAME = 'taos_test'
HOST = 'localhost'
PORT = 6041
db = TdEngineDatabase(DATABASENAME,host=HOST)
# db = TdEngineDatabase(DATABASENAME,host=HOST,port=PORT,user='yourusername',passwd='yourpassword')



class Meter1(Model):
    cur = FloatField(db_column='c1')
    curInt = IntegerField(db_column='c2')
    curDouble = DoubleField(db_column='c3')
    desc = BinaryField(db_column='des')
    class Meta:
        database = db
        db_table = 'meter1'

class AllField(Model):
    name_float = FloatField(column_name='n_float')
    name_double = DoubleField()
    name_bigint = BigIntegerField()
    name_int = IntegerField()
    name_smallint = SmallIntegerField()
    name_tinyint = TinyIntegerField()
    name_nchar = NCharField(max_length=59)
    name_binary = BinaryField(max_length=3)
    name_ = BooleanField()
    dd = PrimaryKeyField()
    birthday = DateTimeField()
    class Meta:
        database = db
        db_table = 'all_field'

creat database and delete database:

db.create_database(safe=True)
# db.create_database(safe=True,keep= 100,comp=0,replica=1,quorum=2,blocks=115)
db.drop_database(safe=True)

alter database:

db.alter_database(keep= 120,comp=1,replica=1,quorum=1,blocks=156)

create drop and exist table:

Meter1.create_table(safe=True)
# db.create_table(Meter1,safe=True)
Meter1.drop_table(safe=True)
# db.drop_table(Meter1,safe=True)
Meter1.table_exists()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/ks_417/crown.git
git@gitee.com:ks_417/crown.git
ks_417
crown
crown
main

搜索帮助