modify nodejs example
This commit is contained in:
parent
01000f7aa9
commit
2355e2f8de
|
@ -24,13 +24,18 @@ async function createConnect() {
|
||||||
async function createDbAndTable() {
|
async function createDbAndTable() {
|
||||||
let wsSql = null;
|
let wsSql = null;
|
||||||
try {
|
try {
|
||||||
wsSql = await createConnect();
|
let conf = new taos.WSConfig(dsn);
|
||||||
|
conf.setUser('root');
|
||||||
|
conf.setPwd('taosdata');
|
||||||
|
conf.setDb('power');
|
||||||
|
wsSql = await taos.sqlConnect(conf);
|
||||||
|
console.log("Connected to " + dsn + " successfully.");
|
||||||
// create database
|
// create database
|
||||||
await wsSql.exec('CREATE DATABASE IF NOT EXISTS power');
|
await wsSql.exec('CREATE DATABASE IF NOT EXISTS power');
|
||||||
console.log("Create database power successfully.");
|
console.log("Create database power successfully.");
|
||||||
// create table
|
// create table
|
||||||
await wsSql.exec('CREATE STABLE IF NOT EXISTS power.meters ' +
|
await wsSql.exec('CREATE STABLE IF NOT EXISTS power.meters ' +
|
||||||
'(_ts timestamp, current float, voltage int, phase float) ' +
|
'(ts timestamp, current float, voltage int, phase float) ' +
|
||||||
'TAGS (location binary(64), groupId int);');
|
'TAGS (location binary(64), groupId int);');
|
||||||
|
|
||||||
console.log("Create stable power.meters successfully");
|
console.log("Create stable power.meters successfully");
|
||||||
|
|
Loading…
Reference in New Issue