未提供项目说明

db-ops的Python项目详细描述


Build StatusCodecovGitHub

sqlite3和InfluxDB数据库的Python类助手。在

SQHelper(SqLite3数据库)

示例:创建、读取和删除只处理数据帧的表。在

fromdbops.sqhelperimportSQHelperimportpandasaspd>>>table_name='temperature'>>>df=pd.DataFrame({"timestamp":[1587222785,1587222786],'celsius':[23.3,23.9]})>>>db='myDatabase.sql3'>>>database=SQHelper(db)# The dataframe column names are used for the table's column names. # All dataframe entries are automatically inserted.>>>database.create_table(table_name,df)['timestamp','celsius']# Add some more entries to the database, in this case duplicates of the above entry are made.>>>database.insert(table_name,df)True# Read the content back into a dataframe>>>database.table_to_df(table_name)celsiustimestamp034.21587222785123.31587222785223.91587222786323.31587222785423.91587222786# Remove the table from the database>>>database.remove_table(table_name);True

示例:创建一个表,添加一个条目并将其作为Pandas dataframe返回。在

^{pr2}$

使用help(SQHelper)获取更多详细信息。在

流入Db

fromdbops.imfluxhelperimportInfluxHelper# Create a class instance for a single database>>>database=InfluxHelper('database_name')# Check the database is connected to OK>>>database.exists()True# Add a new measurement to the database as a dictionary>>>data={'timestamp':1585848415,'temperature':23.3,'humidity':12.2,'room':'kitchen','house':'home'}>>>measurement='Environment'>>>fields=['temperature','humidity']>>>tags=['room','house']>>>database.insert(measurement,data,field_keys=fields,tag_keys=tags,use_timestamp=True)True# Add multiple measurements as a Pandas DataFrame>>>data=[{'timestamp':1585848415,'temperature':23.3,'humidity':12.2,'room':'kitchen','house':'home'},{'timestamp':1585848416,'temperature':22.1,'humidity':13.4,'room':'bedroom','house':'home'}]>>>df=pd.DataFrame(data)>>>measurement='Household'>>>fields=['temperature','humidity']>>>tags=['room','house']>>>database.insert(measurement,df,field_keys=fields,tag_keys=tags,use_timestamp=use_time)True# Get all the measurements in the database>>>database.get_measurement_names()['Environment','Household']# Get the last time based entry in a table>>>last_time_entry=database.get_last_time_entry('Household','humidity','room','bedroom',as_unix=True)>>>last_time_entry['last']13.4>>>last_time_entry['time']1585848416

使用帮助(InfluxHelper)获取更多详细信息。在

版本历史记录

0.1.0

  • 增加了流入数据库的接口
  • 添加了一些时间戳转换实用程序
  • 改进的文档

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Java类/接口中的编码风格默认注释和元信息   java列表不为空,但poll方法返回null   java无法在安卓中设置视图   java在游戏中后台运行计数器线程   带有ForEach迭代问题的Java流   java OpenApi(Swagger 3.0)Codegen缺少验证   JAVAlang.RuntimeException:无法传递结果ResultInfo需要安卓。准许读取外部存储器或grantUriPermissio   新Java Spring启动项目应用程序引擎部署失败,错误代码为13   用户输入的java验证   如何使用java将连续的JSON对象转换为csv   java正则表达式以删除所有不可打印字符   如何告诉编译器在Android应用程序中使用Kotlin扩展函数而不是Java 8函数   java你能制作Tomcat 6标准吗。日志文件的行为是否像log4j DailRollingFileAppender?   当使用操作符重载时,在闭包中或甚至在方法中更新时,不会发生对我的列表的java更新   java错误解析jar上带有入口点创建的文件参数错误