使用 revoscalepy 将数据插入数据库 [英] Using revoscalepy to insert data into a database

查看:41
本文介绍了使用 revoscalepy 将数据插入数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

是否有可能使用 revoscalepy 包将值插入表中?

is there a possibility of using the revoscalepy package to insert values into a table?

我希望得到以下内容:

import pandas as pd
from revoscalepy import rx_write_to_db, RxOdbcData

a_df = pd.DataFrame([[0, 1], [2, 3]], columns=[...])

rx_write_to_db(RxOdbcData(connection_string=con_str, ...), data=a_df)

但是我找不到这样的东西.最接近的选项似乎是 rx_write_object,它将数据帧作为二进制文件转储到表中.有关用法的更多信息可以在R-package 站点. 然而这并不能解决我的问题,因为我希望数据不在一个二进制 blob 中.

But I couldn't find anything like this. The closest option appears to be rx_write_object, which dumps the dataframe as a binary into the table. More information about the usage can be found on the R-package site. This however does not solve my issue, as I would that the data is not in one binary blob.

关于这个问题的一些背景:在特征生成期间,我创建了多个特征,我想将这些特征存储在数据库中以备后用.理论上,我可以创建一个包含我所有功能和元数据的最终数据框,并使用一些触发器将数据转储到正确的表中,但在我这样做之前,我宁愿安装 pymssql.

Some context on the problem: During the feature generation I create multiple features which I want to store inside the database for later use. In theory I could create a final dataframe with all my features and the meta-data in it and use some triggers to dump the data into the right tables, but before I do this, I would rather install pymssql.

有什么线索吗?

Ps.:如果有人知道此类问题的正确标签,请告诉我...

Ps.: If anyone knows the correct tags for a question like this, let me know...

推荐答案

我认为您正在寻找的是来自 microsoftml 包的 rx_featurize (Installed with revoscalepy)

I think what you are looking for is rx_featurize from microsoftml package (Installed with revoscalepy)

获得数据框后,您将使用连接字符串和表名参数创建 RxSqlServerData 或 RxOdbcData.

After you have your data frame, you would create a RxSqlServerData or RxOdbcData, with the connection string and table name arguments.

然后您只需调用 rx_featurize 将数据帧作为输入,将 Rx...Data 对象作为输出(指定是否要覆盖表)

Then you simply call rx_featurize giving it the data frame as input and the Rx...Data object as output (specifying if you want to overwrite the table or not)

http://docs.microsoft.com/en-us/machine-learning-server/python-reference/microsoftml/rx-featurize

import pandas as pd
from revoscalepy import RxOdbcData
from microsoftml import rx_featurize

a_df = pd.DataFrame([[0, 1], [2, 3]], columns=[...])

rx_featurize(data=a_df,output_data=RxOdbcData(connection_string=con_str, table = tablename), overwrite = True)

这篇关于使用 revoscalepy 将数据插入数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆