mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 10:58:35 +08:00
@@ -6,15 +6,15 @@ const logTableName = "device_log"
|
|||||||
|
|
||||||
// CreateLogStable 添加LOG超级表
|
// CreateLogStable 添加LOG超级表
|
||||||
func (s *TdEngine) CreateLogStable() (err error) {
|
func (s *TdEngine) CreateLogStable() (err error) {
|
||||||
sql := "CREATE STABLE IF NOT EXISTS device_log (ts TIMESTAMP, type VARCHAR(20), content VARCHAR(1000)) TAGS (device VARCHAR(255))"
|
sql := "CREATE STABLE IF NOT EXISTS ? (ts TIMESTAMP, type VARCHAR(20), content VARCHAR(1000)) TAGS (device VARCHAR(255))"
|
||||||
_, err = s.db.Exec(sql)
|
_, err = s.db.Exec(sql, logTableName)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// InsertLog 写入数据
|
// InsertLog 写入数据
|
||||||
func (s *TdEngine) InsertLog(log *TdLog) (err error) {
|
func (s *TdEngine) InsertLog(log *TdLog) (err error) {
|
||||||
sql := "INSERT INTO log_? USING device_log TAGS (?) VALUES (?, ?, ?)"
|
sql := "INSERT INTO log_? USING device_log TAGS (?) VALUES (?, ?, ?)"
|
||||||
_, err = s.db.Exec(sql, log.Device, log.Device, log.Ts, log.Type, log.Content)
|
_, err = s.db.Exec(sql, log.Device, log.Ts, log.Type, log.Content)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user