Merge branch 'docs/sheyj-3.0' of github.com:taosdata/TDengine into docs/sheyj-3.0
This commit is contained in:
commit
85e6492ac4
|
@ -62,7 +62,7 @@ async function subscribe(consumer) {
|
||||||
for (let [key, value] of res) {
|
for (let [key, value] of res) {
|
||||||
console.log(`data: ${key} ${value}`);
|
console.log(`data: ${key} ${value}`);
|
||||||
}
|
}
|
||||||
consumer.commit();
|
await consumer.commit();
|
||||||
console.log("Commit offset manually successfully.");
|
console.log("Commit offset manually successfully.");
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -77,7 +77,7 @@ async function test() {
|
||||||
let consumer = null;
|
let consumer = null;
|
||||||
try {
|
try {
|
||||||
await prepare();
|
await prepare();
|
||||||
let consumer = await createConsumer()
|
consumer = await createConsumer()
|
||||||
await subscribe(consumer)
|
await subscribe(consumer)
|
||||||
await consumer.unsubscribe();
|
await consumer.unsubscribe();
|
||||||
console.log("Consumer unsubscribed successfully.");
|
console.log("Consumer unsubscribed successfully.");
|
||||||
|
|
|
@ -31,7 +31,7 @@ async function prepare() {
|
||||||
conf.setUser('root');
|
conf.setUser('root');
|
||||||
conf.setPwd('taosdata');
|
conf.setPwd('taosdata');
|
||||||
conf.setDb('power');
|
conf.setDb('power');
|
||||||
const createDB = `CREATE DATABASE IF NOT EXISTS POWER ${db} KEEP 3650 DURATION 10 BUFFER 16 WAL_LEVEL 1;`;
|
const createDB = `CREATE DATABASE IF NOT EXISTS ${db} KEEP 3650 DURATION 10 BUFFER 16 WAL_LEVEL 1;`;
|
||||||
const createStable = `CREATE STABLE IF NOT EXISTS ${db}.${stable} (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int);`;
|
const createStable = `CREATE STABLE IF NOT EXISTS ${db}.${stable} (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int);`;
|
||||||
|
|
||||||
let wsSql = await taos.sqlConnect(conf);
|
let wsSql = await taos.sqlConnect(conf);
|
||||||
|
@ -45,7 +45,7 @@ async function prepare() {
|
||||||
for (let i = 0; i < 10; i++) {
|
for (let i = 0; i < 10; i++) {
|
||||||
await wsSql.exec(`INSERT INTO d1001 USING ${stable} (location, groupId) TAGS ("California.SanFrancisco", 3) VALUES (NOW, ${10 + i}, ${200 + i}, ${0.32 + i})`);
|
await wsSql.exec(`INSERT INTO d1001 USING ${stable} (location, groupId) TAGS ("California.SanFrancisco", 3) VALUES (NOW, ${10 + i}, ${200 + i}, ${0.32 + i})`);
|
||||||
}
|
}
|
||||||
wsSql.Close();
|
await wsSql.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ANCHOR: subscribe
|
// ANCHOR: subscribe
|
||||||
|
|
|
@ -1,19 +1,21 @@
|
||||||
import taosws
|
import taosws
|
||||||
|
|
||||||
|
host = "localhost"
|
||||||
|
port = 6041
|
||||||
def prepare():
|
def prepare():
|
||||||
conn = None
|
conn = None
|
||||||
try:
|
try:
|
||||||
conn = taosws.connect(user="root",
|
conn = taosws.connect(user="root",
|
||||||
password="taosdata",
|
password="taosdata",
|
||||||
host="localhost",
|
host=host,
|
||||||
port=6041)
|
port=port)
|
||||||
|
|
||||||
# create database
|
# create database
|
||||||
rowsAffected = conn.execute(f"CREATE DATABASE IF NOT EXISTS power")
|
rowsAffected = conn.execute(f"CREATE DATABASE IF NOT EXISTS power")
|
||||||
assert rowsAffected == 0
|
assert rowsAffected == 0
|
||||||
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
print(f"Failed to create db and table, err:{err}")
|
print(f"Failed to create db and table, db addrr:{host}:{port} ; ErrMessage:{err}")
|
||||||
raise err
|
raise err
|
||||||
finally:
|
finally:
|
||||||
if conn:
|
if conn:
|
||||||
|
@ -32,8 +34,7 @@ def schemaless_insert():
|
||||||
jsonDemo = [
|
jsonDemo = [
|
||||||
'{"metric": "metric_json","timestamp": 1626846400,"value": 10.3, "tags": {"groupid": 2, "location": "California.SanFrancisco", "id": "d1001"}}'
|
'{"metric": "metric_json","timestamp": 1626846400,"value": 10.3, "tags": {"groupid": 2, "location": "California.SanFrancisco", "id": "d1001"}}'
|
||||||
]
|
]
|
||||||
host = "localhost"
|
|
||||||
port = 6041
|
|
||||||
try:
|
try:
|
||||||
conn = taosws.connect(user="root",
|
conn = taosws.connect(user="root",
|
||||||
password="taosdata",
|
password="taosdata",
|
||||||
|
@ -76,6 +77,6 @@ def schemaless_insert():
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
prepare()
|
prepare()
|
||||||
schemaless_insert
|
schemaless_insert()
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
print(f"Failed to insert data with schemaless, err:{err}")
|
print(f"Failed to insert data with schemaless, err:{err}")
|
||||||
|
|
|
@ -7,8 +7,8 @@ numOfRow = 10
|
||||||
|
|
||||||
conn = None
|
conn = None
|
||||||
stmt = None
|
stmt = None
|
||||||
host="localhost",
|
host="localhost"
|
||||||
port=6030,
|
port=6030
|
||||||
try:
|
try:
|
||||||
conn = taos.connect(
|
conn = taos.connect(
|
||||||
user="root",
|
user="root",
|
||||||
|
|
|
@ -13,8 +13,8 @@ port=6041
|
||||||
try:
|
try:
|
||||||
conn = taosws.connect(user="root",
|
conn = taosws.connect(user="root",
|
||||||
password="taosdata",
|
password="taosdata",
|
||||||
host="localhost",
|
host=host,
|
||||||
port=6041)
|
port=port)
|
||||||
|
|
||||||
conn.execute("CREATE DATABASE IF NOT EXISTS power")
|
conn.execute("CREATE DATABASE IF NOT EXISTS power")
|
||||||
conn.execute("USE power")
|
conn.execute("USE power")
|
||||||
|
|
|
@ -50,7 +50,7 @@ from taos.tmq import Consumer
|
||||||
|
|
||||||
def create_consumer():
|
def create_consumer():
|
||||||
host = "localhost"
|
host = "localhost"
|
||||||
port = 6030
|
port = "6030"
|
||||||
groupId = "group1"
|
groupId = "group1"
|
||||||
clientId = "1"
|
clientId = "1"
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -146,7 +146,7 @@ Note: 从 3.0.1.7 开始,只提供 TDengine 客户端的 Windows 客户端的
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
:::info
|
:::info
|
||||||
下载其他组件、最新 Beta 版及之前版本的安装包,请点击[发布历史页面](../../releases/tdengine)。
|
下载其他组件、最新 Beta 版及之前版本的安装包,请点击[发布历史页面](https://docs.taosdata.com/releases/tdengine/)。
|
||||||
:::
|
:::
|
||||||
|
|
||||||
:::note
|
:::note
|
||||||
|
|
Loading…
Reference in New Issue