So far Python still does not completely support nanosecond type. Please refer to the link 1 and 2. The implementation of the python connector is to return an integer number for nanosecond value rather than datatime type as what ms and us do. The developer needs to handle it themselves. We recommend using pandas to_datetime() function. If Python officially support nanosecond in the future, TAOS Data might be possible to change the interface accordingly, which mean the application need change too.
Users can directly view the usage information of the module through Python's helper, or refer to the sample program in tests/examples/Python. The following are some common classes and methods:
Users can directly view the usage information of the module through Python's helper, or refer to the sample program in tests/examples/Python. The following are some common classes and methods:
Stringsql="Insert into t3 using weather tags('广东') values('2020-01-01 01:0:00.000', 22.22),('2020-01-01 02:00:00.000', 22.22) t4 using weather tags('天津') values('2020-01-01 01:0:00.000', 33.33),('2020-01-01 02:00:00.000', 33.33)";
Stringsql="Insert into t3 using weather tags('广东') values('2020-01-01 01:0:00.000', 22.22),('2020-01-01 02:00:00.000', 22.22) t4 using weather tags('天津') values('2020-01-01 01:0:00.000', 33.33),('2020-01-01 02:00:00.000', 33.33)";
SQLExecutor.executeUpdate(connection,sql);
// when
booleanexecute=execute(connection,sql);
// then
Assert.assertFalse(execute);
}
}
@Test
@Test
publicvoidtestCase018(){
publicvoidtestCase018(){
// given
Stringsql="select * from restful_test.t1";
Stringsql="select * from restful_test.t1";
SQLExecutor.executeQuery(connection,sql);
// when
booleanexecute=execute(connection,sql);
// then
Assert.assertTrue(execute);
}
}
@Test
@Test
publicvoidtestCase019(){
publicvoidtestCase019(){
// given
Stringsql="select * from restful_test.weather";
Stringsql="select * from restful_test.weather";
SQLExecutor.executeQuery(connection,sql);
// when
booleanexecute=execute(connection,sql);
// then
Assert.assertTrue(execute);
}
}
@Test
@Test
publicvoidtestCase020(){
publicvoidtestCase020(){
// given
Stringsql="select ts, temperature from restful_test.t1";
Stringsql="select ts, temperature from restful_test.t1";
SQLExecutor.executeQuery(connection,sql);
// when
booleanexecute=execute(connection,sql);
// then
Assert.assertTrue(execute);
}
}
@Test
@Test
publicvoidtestCase021(){
publicvoidtestCase021(){
// given
Stringsql="select ts, temperature from restful_test.weather";
Stringsql="select ts, temperature from restful_test.weather";
SQLExecutor.executeQuery(connection,sql);
// when
booleanexecute=execute(connection,sql);
// then
Assert.assertTrue(execute);
}
}
@Test
@Test
publicvoidtestCase022(){
publicvoidtestCase022(){
// given
Stringsql="select temperature, ts from restful_test.t1";
Stringsql="select temperature, ts from restful_test.t1";
SQLExecutor.executeQuery(connection,sql);
// when
booleanexecute=execute(connection,sql);
// then
Assert.assertTrue(execute);
}
}
@Test
@Test
publicvoidtestCase023(){
publicvoidtestCase023(){
// given
Stringsql="select temperature, ts from restful_test.weather";
Stringsql="select temperature, ts from restful_test.weather";
SQLExecutor.executeQuery(connection,sql);
// when
booleanexecute=execute(connection,sql);
// then
Assert.assertTrue(execute);
}
}
@Test
@Test
publicvoidtestCase024(){
publicvoidtestCase024(){
// given
Stringsql="import into restful_test.t5 using weather tags('石家庄') values('2020-01-01 00:01:00.000', 22.22)";
Stringsql="import into restful_test.t5 using weather tags('石家庄') values('2020-01-01 00:01:00.000', 22.22)";
SQLExecutor.executeUpdate(connection,sql);
// when
intaffectedRows=executeUpdate(connection,sql);
// then
Assert.assertEquals(1,affectedRows);
}
}
@Test
@Test
publicvoidtestCase025(){
publicvoidtestCase025(){
// given
Stringsql="import into restful_test.t6 using weather tags('沈阳') values('2020-01-01 00:01:00.000', 22.22),('2020-01-01 00:02:00.000', 22.22)";
Stringsql="import into restful_test.t6 using weather tags('沈阳') values('2020-01-01 00:01:00.000', 22.22),('2020-01-01 00:02:00.000', 22.22)";
SQLExecutor.executeUpdate(connection,sql);
// when
intaffectedRows=executeUpdate(connection,sql);
// then
Assert.assertEquals(2,affectedRows);
}
}
@Test
@Test
publicvoidtestCase026(){
publicvoidtestCase026(){
// given
Stringsql="import into restful_test.t7 using weather tags('长沙') values('2020-01-01 00:01:00.000', 22.22) restful_test.t8 using weather tags('吉林') values('2020-01-01 00:01:00.000', 22.22)";
Stringsql="import into restful_test.t7 using weather tags('长沙') values('2020-01-01 00:01:00.000', 22.22) restful_test.t8 using weather tags('吉林') values('2020-01-01 00:01:00.000', 22.22)";
SQLExecutor.executeUpdate(connection,sql);
// when
intaffectedRows=executeUpdate(connection,sql);
// then
Assert.assertEquals(2,affectedRows);
}
}
@Test
@Test
publicvoidtestCase027(){
publicvoidtestCase027(){
// given
Stringsql="import into restful_test.t9 using weather tags('武汉') values('2020-01-01 00:01:00.000', 22.22) ,('2020-01-02 00:01:00.000', 22.22) restful_test.t10 using weather tags('哈尔滨') values('2020-01-01 00:01:00.000', 22.22),('2020-01-02 00:01:00.000', 22.22)";
Stringsql="import into restful_test.t9 using weather tags('武汉') values('2020-01-01 00:01:00.000', 22.22) ,('2020-01-02 00:01:00.000', 22.22) restful_test.t10 using weather tags('哈尔滨') values('2020-01-01 00:01:00.000', 22.22),('2020-01-02 00:01:00.000', 22.22)";
SQLExecutor.executeUpdate(connection,sql);
// when
intaffectedRows=executeUpdate(connection,sql);
// then
Assert.assertEquals(4,affectedRows);
}
}
@Test
@Test
publicvoidtestCase028(){
publicvoidtestCase028(){
// given
Stringsql="select location, temperature, ts from restful_test.weather where temperature > 1";
Stringsql="select location, temperature, ts from restful_test.weather where temperature > 1";
SQLExecutor.executeQuery(connection,sql);
// when
ResultSetrs=executeQuery(connection,sql);
// then
Assert.assertNotNull(rs);
}
}
@Test
@Test
publicvoidtestCase029(){
publicvoidtestCase029(){
Stringsql="select location, temperature, ts from restful_test.weather where temperature < 1";
Stringsql="select location, temperature, ts from restful_test.weather where temperature < 1";
SQLExecutor.executeQuery(connection,sql);
// when
ResultSetrs=executeQuery(connection,sql);
// then
Assert.assertNotNull(rs);
}
}
@Test
@Test
publicvoidtestCase030(){
publicvoidtestCase030(){
Stringsql="select location, temperature, ts from restful_test.weather where ts > now";
Stringsql="select location, temperature, ts from restful_test.weather where ts > now";
SQLExecutor.executeQuery(connection,sql);
// when
ResultSetrs=executeQuery(connection,sql);
// then
Assert.assertNotNull(rs);
}
}
@Test
@Test
publicvoidtestCase031(){
publicvoidtestCase031(){
Stringsql="select location, temperature, ts from restful_test.weather where ts < now";
Stringsql="select location, temperature, ts from restful_test.weather where ts < now";
SQLExecutor.executeQuery(connection,sql);
// when
ResultSetrs=executeQuery(connection,sql);
// then
Assert.assertNotNull(rs);
}
}
@Test
@Test
publicvoidtestCase032(){
publicvoidtestCase032(){
Stringsql="select count(*) from restful_test.weather";
Stringsql="select count(*) from restful_test.weather";
SQLExecutor.executeQuery(connection,sql);
// when
ResultSetrs=executeQuery(connection,sql);
// then
Assert.assertNotNull(rs);
}
}
@Test
@Test
publicvoidtestCase033(){
publicvoidtestCase033(){
Stringsql="select first(*) from restful_test.weather";
Stringsql="select first(*) from restful_test.weather";
SQLExecutor.executeQuery(connection,sql);
// when
ResultSetrs=executeQuery(connection,sql);
// then
Assert.assertNotNull(rs);
}
}
@Test
@Test
publicvoidtestCase034(){
publicvoidtestCase034(){
Stringsql="select last(*) from restful_test.weather";
Stringsql="select last(*) from restful_test.weather";
SQLExecutor.executeQuery(connection,sql);
// when
ResultSetrs=executeQuery(connection,sql);
// then
Assert.assertNotNull(rs);
}
}
@Test
@Test
publicvoidtestCase035(){
publicvoidtestCase035(){
Stringsql="select last_row(*) from restful_test.weather";
Stringsql="select last_row(*) from restful_test.weather";
SQLExecutor.executeQuery(connection,sql);
// when
ResultSetrs=executeQuery(connection,sql);
// then
Assert.assertNotNull(rs);
}
}
@Test
@Test
publicvoidtestCase036(){
publicvoidtestCase036(){
Stringsql="select ts, ts as primary_key from restful_test.weather";
Stringsql="select ts, ts as primary_key from restful_test.weather";