Merge branch 'docs/sheyj-3.0' of github.com:taosdata/TDengine into docs/sheyj-3.0
This commit is contained in:
commit
583c1e46d6
|
@ -73,4 +73,6 @@ static int DemoCreateDB() {
|
||||||
// ANCHOR_END: create_db_and_table
|
// ANCHOR_END: create_db_and_table
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) { return DemoCreateDB(); }
|
int main(int argc, char *argv[]) {
|
||||||
|
return DemoCreateDB();
|
||||||
|
}
|
||||||
|
|
|
@ -71,4 +71,6 @@ static int DemoInsertData() {
|
||||||
// ANCHOR_END: insert_data
|
// ANCHOR_END: insert_data
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) { return DemoInsertData(); }
|
int main(int argc, char *argv[]) {
|
||||||
|
return DemoInsertData();
|
||||||
|
}
|
||||||
|
|
|
@ -62,9 +62,12 @@ static int DemoQueryData() {
|
||||||
// fetch the records row by row
|
// fetch the records row by row
|
||||||
while ((row = taos_fetch_row(result))) {
|
while ((row = taos_fetch_row(result))) {
|
||||||
char temp[1024] = {0};
|
char temp[1024] = {0};
|
||||||
rows++;
|
if (taos_print_row(temp, row, fields, num_fields) < 0) {
|
||||||
taos_print_row(temp, row, fields, num_fields);
|
printf("Failed to print row\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
printf("%s\n", temp);
|
printf("%s\n", temp);
|
||||||
|
rows++;
|
||||||
}
|
}
|
||||||
printf("total rows: %d\n", rows);
|
printf("total rows: %d\n", rows);
|
||||||
taos_free_result(result);
|
taos_free_result(result);
|
||||||
|
@ -76,4 +79,6 @@ static int DemoQueryData() {
|
||||||
// ANCHOR_END: query_data
|
// ANCHOR_END: query_data
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) { return DemoQueryData(); }
|
int main(int argc, char *argv[]) {
|
||||||
|
return DemoQueryData();
|
||||||
|
}
|
||||||
|
|
|
@ -48,7 +48,6 @@ static int DemoSmlInsert() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
taos_free_result(result);
|
taos_free_result(result);
|
||||||
printf("Create database power successfully.\n");
|
|
||||||
|
|
||||||
// use database
|
// use database
|
||||||
result = taos_query(taos, "USE power");
|
result = taos_query(taos, "USE power");
|
||||||
|
@ -136,4 +135,6 @@ static int DemoSmlInsert() {
|
||||||
// ANCHOR_END: schemaless
|
// ANCHOR_END: schemaless
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) { return DemoSmlInsert(); }
|
int main(int argc, char *argv[]) {
|
||||||
|
return DemoSmlInsert();
|
||||||
|
}
|
||||||
|
|
|
@ -132,7 +132,6 @@ static int32_t init_env() {
|
||||||
|
|
||||||
TAOS_RES* pRes;
|
TAOS_RES* pRes;
|
||||||
// drop database if exists
|
// drop database if exists
|
||||||
fprintf(stdout, "Create database.\n");
|
|
||||||
pRes = taos_query(pConn, "DROP TOPIC IF EXISTS topic_meters");
|
pRes = taos_query(pConn, "DROP TOPIC IF EXISTS topic_meters");
|
||||||
code = taos_errno(pRes);
|
code = taos_errno(pRes);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
|
@ -157,7 +156,6 @@ static int32_t init_env() {
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
||||||
// create super table
|
// create super table
|
||||||
fprintf(stdout, "Create super table.\n");
|
|
||||||
pRes = taos_query(
|
pRes = taos_query(
|
||||||
pConn,
|
pConn,
|
||||||
"CREATE STABLE IF NOT EXISTS power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS "
|
"CREATE STABLE IF NOT EXISTS power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS "
|
||||||
|
@ -179,7 +177,6 @@ END:
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t create_topic() {
|
int32_t create_topic() {
|
||||||
fprintf(stdout, "Create topic.\n");
|
|
||||||
TAOS_RES* pRes;
|
TAOS_RES* pRes;
|
||||||
const char* host = "localhost";
|
const char* host = "localhost";
|
||||||
const char* user = "root";
|
const char* user = "root";
|
||||||
|
@ -382,7 +379,6 @@ void manual_commit(tmq_t* tmq) {
|
||||||
totalRows += msg_process(tmqmsg);
|
totalRows += msg_process(tmqmsg);
|
||||||
// commit the message
|
// commit the message
|
||||||
int32_t code = tmq_commit_sync(tmq, tmqmsg);
|
int32_t code = tmq_commit_sync(tmq, tmqmsg);
|
||||||
|
|
||||||
if (code) {
|
if (code) {
|
||||||
fprintf(stderr, "Failed to commit message, ErrCode: 0x%x, ErrMessage: %s.\n", code, tmq_err2str(code));
|
fprintf(stderr, "Failed to commit message, ErrCode: 0x%x, ErrMessage: %s.\n", code, tmq_err2str(code));
|
||||||
// free the message
|
// free the message
|
||||||
|
|
|
@ -62,9 +62,12 @@ static int DemoWithReqId() {
|
||||||
// fetch the records row by row
|
// fetch the records row by row
|
||||||
while ((row = taos_fetch_row(result))) {
|
while ((row = taos_fetch_row(result))) {
|
||||||
char temp[1024] = {0};
|
char temp[1024] = {0};
|
||||||
rows++;
|
if (taos_print_row(temp, row, fields, num_fields) < 0) {
|
||||||
taos_print_row(temp, row, fields, num_fields);
|
printf("Failed to print row\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
printf("%s\n", temp);
|
printf("%s\n", temp);
|
||||||
|
rows++;
|
||||||
}
|
}
|
||||||
printf("total rows: %d\n", rows);
|
printf("total rows: %d\n", rows);
|
||||||
taos_free_result(result);
|
taos_free_result(result);
|
||||||
|
@ -76,4 +79,6 @@ static int DemoWithReqId() {
|
||||||
// ANCHOR_END: with_reqid
|
// ANCHOR_END: with_reqid
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) { return DemoWithReqId(); }
|
int main(int argc, char *argv[]) {
|
||||||
|
return DemoWithReqId();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue