Skip to content

Commit a5944e8

Browse files
feat: support go database client
1 parent 7f4315a commit a5944e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+25770
-1
lines changed

client/session.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,17 @@ func (s *Session) ExecuteStatement(sql string) (*SessionDataSet, error) {
491491
return s.ExecuteStatementWithContext(context.Background(), sql)
492492
}
493493

494+
func (s *Session) Ping(ctx context.Context) error {
495+
status, err := s.client.TestConnectionEmptyRPC(ctx)
496+
if err != nil {
497+
return err
498+
}
499+
if status.GetCode() == SuccessStatus {
500+
return nil
501+
}
502+
return errors.New("Ping failed: " + status.GetMessage())
503+
}
504+
494505
func (s *Session) ExecuteNonQueryStatement(sql string) (r *common.TSStatus, err error) {
495506
request := rpc.TSExecuteStatementReq{
496507
SessionId: s.sessionId,

database/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea
2+
vendor

database/batch.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package iotdb_go
2+
3+
import (
4+
"context"
5+
"database/sql/driver"
6+
"github.com/pkg/errors"
7+
)
8+
9+
type stdBatch struct {
10+
debugf func(format string, v ...any)
11+
}
12+
13+
func (s *stdBatch) NumInput() int { return -1 }
14+
15+
func (s *stdBatch) Exec(args []driver.Value) (driver.Result, error) {
16+
return nil, errors.New("not implemented")
17+
}
18+
19+
func (s *stdBatch) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error) {
20+
return nil, driver.ErrSkip
21+
}
22+
23+
func (s *stdBatch) Query(args []driver.Value) (driver.Rows, error) {
24+
// Note: not implementing driver.StmtQueryContext accordingly
25+
return nil, errors.New("only Exec method supported in batch mode")
26+
}
27+
28+
func (s *stdBatch) Close() error {
29+
return nil
30+
}

0 commit comments

Comments
 (0)