未验证 提交 97d728d1 编写于 作者: X xiaolei li 提交者: GitHub

[TD-14212]<fix>:add R example code to CI 1st (#10921)

* [TD-14212]<test>:add R example code to CI 1st

* [TD-14212]<fix>:add R example code to CI 2nd

* [TD-14212]<fix>:add R example code to CI 3rd

* [TD-14212]<fix>:add R example code to CI 4th

* [TD-14212]<fix>:add R example code to CI 5th

* [TD-14212]<fix>:add R example code to CI 6th

* [TD-14212]<fix>:add R example code to CI 7th

* [TD-14212]<fix>:add R example code to CI 8th

* [TD-14212]<fix>:add R example code to CI 9th

* [TD-14212]<fix>:add R example code to CI,fix typo
上级 a4761bd0
# Linux Platform
install.packages('rJDBC', repos='http://cran.us.r-project.org')
install.packages('RJDBC', repos='http://cran.us.r-project.org')
# Loading RJDBC packages
library('RJDBC')
......
#install.packages('RJDBC', repos='http://cran.us.r-project.org')
library('DBI')
library('rJava')
library('RJDBC')
# get jdbc from input parameters
args<- commandArgs(trailingOnly = TRUE)
# arg[1] for jdbc path,arg[2] fro jdbc name
# like "/src/connector/jdbc/target/taos-jdbcdriver-2.0.37-dist.jar"
jdbc<- paste(args[1],args[2],sep="/")
print("***************************taos-jdbcDriver support RJDBC sample *************************************")
#JNI
# Get JBDC-JNI connection
drv<-JDBC("com.taosdata.jdbc.TSDBDriver",jdbc, identifier.quote="\"")
conn<-dbConnect(drv,"jdbc:TAOS://127.0.0.1:6030/?user=root&password=taosdata","root","taosdata")
#Restful
#drv<-JDBC("com.taosdata.jdbc.TSDBDriver",jdbc, identifier.quote="\"")
#conn<-dbConnect(drv,"jdbc:TAOS-RS://127.0.0.1:6041/test?user=root&password=taosdata","root","taosdata")
# Get connection information
dbGetInfo(conn)
# create database
dbSendUpdate(conn,"create database if not exists r_example_db keep 3650")
# use db
dbSendUpdate(conn,"use r_example_db")
dbSendUpdate(conn,"create table if not exists test(ts timestamp,i8 tinyint,i16 smallint,i32 int,i64 bigint,bnry binary(50),nchr nchar(50)) tags(k int,v binary(20))")
# insert data
dbSendUpdate(conn,"insert into test_s01 using test tags(1,'sub_01') values(now,1,2,3,4,'binary1','nchar1')(now+1s,5,6,7,8,'binary2','nchar2')(now+2s,9,0,1,2,'binary3','nchar3')")
# View all tables
print("==============dbGetQuery==================")
table1<-dbGetQuery(conn,"select * from test")
print(table1)
# Functional support for RJDBC
# List all tables
print("=============dbListTables===================")
dbListTables(conn,"test%")
print("=============dbExistsTable===================")
# Is there table "test"
dbExistsTable(conn,"test")
# Connect summary information
print("=============summary===================")
summary(conn)
print("=============dbGetInfo===================")
dbGetInfo(conn)
# Read all the data from the test table
print("=============dbReadTable===================")
dbReadTable(conn,"test")
# Execute any non-query SQL statements
dbSendUpdate(conn, "create table if not exists t1(ts timestamp,id int,u nchar(40))")
dbGetTables(conn, "t")
sampleData=data.frame(ts=c('2022-03-22 00:00:00.000','2022-03-22 10:00:00.000'),id=c(1,2),u=c('涛思数据','TDengine'))
print("=============dbWriteTable===================")
dbWriteTable(conn, "t1", sampleData, overwrite=FALSE, append=TRUE)
dbReadTable(conn,"t1")
# Delete table t1
dbRemoveTable(conn,"t1")
# Extracting data on demand using SQL statements
print("=============dbGetQuery===================")
dbGetQuery(conn, "select * from test_s01")
# Drop database
dbSendUpdate(conn,"drop database if exists r_example_db")
# Close the connection
print("=============dbDisconnect===================")
dbDisconnect(conn)
print("***************************taos-jdbcDriver support RJDBC sample done*************************************")
#!/bin/sh
function stopTaosd {
echo "Stop taosd"
sudo systemctl stop taosd || echo 'no sudo or systemctl or stop fail'
PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
while [ -n "$PID" ]
do
pkill -TERM -x taosd
sleep 1
PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
done
}
stopTaosd
rm -rf /var/lib/taos/*
rm -rf /var/log/taos/*
nohup taosd -c /etc/taos/ > /dev/null 2>&1 &
sleep 10
ls -al
cd ../../
WKC=`pwd`
#echo "WKC:${WKC}"
JDBC_PATH=${WKC}'/src/connector/jdbc/'
CASE_PATH=${WKC}'/tests/examples/R/'
cd ${JDBC_PATH}
#echo "JDBC_PATH:${JDBC_PATH}"
#echo "CASE_PATH:${CASE_PATH}"
mvn clean package -Dmaven.test.skip=true
JDBC=`ls target|grep dist.jar`
JDBC_PATH=${JDBC_PATH}target
#echo ${jdbc}
#echo ${jdbc_path}
cd ${WKC}
# remove
Rscript ${CASE_PATH}rjdbc.sample.R ${JDBC_PATH} ${JDBC}
......@@ -36,7 +36,7 @@
83,,script,./test.sh -f general/parser/limit1_tblocks100.sim
82,,script,./test.sh -f general/parser/limit1.sim
82,,pytest,python3 test.py -f query/last_row_cache.py
81,,develop-test,timeout 180 bash 3-connectors/c#/test.sh
81,,develop-test,timeout 180 bash 3-connectors/c#/test.sh
80,,develop-test,timeout 180 bash 3-connectors/nodejs/test.sh
79,,script,./test.sh -f general/db/alter_tables_v4.sim
79,,pytest,python3 test.py -f insert/verifyMemToDiskCrash.py
......@@ -803,3 +803,4 @@
1,,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/demo.py
8,,pytest,python3 test.py -f update/update2.py
4,,pytest,python3 test.py -f insert/line_insert.py
80,,develop-test,bash 3-connectors/R/test.sh
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册