We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
驱动版本 _ "github.com/taosdata/driver-go/v3/taosWS", 显示指向[email protected]
建表及手动测试都没问题: create table demo(_ts timestamp, col1 varchar(16), col2 varchar(16)); // 建表语句 insert into demo values(NOW(), "123","123"); //手动执行成功 insert into demo values(NOW(), "123","abc"); //手动执行成功
但是用代码占位符方式写数据报错: ` func Test_InsertDemo(t *testing.T) { cfg := config.LoadConfig("../../../config.json").Taos
var taosUri = fmt.Sprintf("%s:%s@%s(%s)/%s", cfg.Username, cfg.Password, cfg.Protocol, cfg.Address, cfg.DBName) if len(cfg.Param) > 0 { taosUri = fmt.Sprintf("%s?params=%s", taosUri, cfg.Param) } db, err := sql.Open("taosWS", taosUri) if err != nil { fmt.Println("failed to connect TDengine, err:", err) t.Fail() } if err = db.Ping(); err != nil { t.Fail() } stmt := "INSERT INTO demo values(?,?,?)" if _, err := db.Exec(stmt, time.Now(), "123", "123"); err != nil { //成功 fmt.Println("1 exec failed:", err.Error()) } else { fmt.Println("1: success") } //失败,报错syntax error near 'abc);' (invalid data or symbol) (0.000197s) // 和手动执行:insert into demo values(NOW(), "123",abc); 报错一样 if _, err := db.Exec(stmt, time.Now(), "123", "abc"); err != nil { //失败,报错syntax error near 'abc);' (invalid data or symbol) (0.000197s) fmt.Println("2 exec failed: ", err.Error()) } else { fmt.Println("2: success") }
} 打印结果: === RUN Test_InsertDemo 1: success 2 exec failed: [0x216] syntax error near 'abc)' (invalid data or symbol) `
打印结果:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
驱动版本 _ "github.com/taosdata/driver-go/v3/taosWS", 显示指向[email protected]
建表及手动测试都没问题:
create table demo(_ts timestamp, col1 varchar(16), col2 varchar(16)); // 建表语句
insert into demo values(NOW(), "123","123"); //手动执行成功
insert into demo values(NOW(), "123","abc"); //手动执行成功
但是用代码占位符方式写数据报错:
`
func Test_InsertDemo(t *testing.T) {
cfg := config.LoadConfig("../../../config.json").Taos
}
打印结果:
=== RUN Test_InsertDemo
1: success
2 exec failed: [0x216] syntax error near 'abc)' (invalid data or symbol)
`
The text was updated successfully, but these errors were encountered: