Skip to content

Commit

Permalink
new update
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueStorm001 committed Oct 12, 2021
1 parent 471ed05 commit 4a08532
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 25 deletions.
21 changes: 13 additions & 8 deletions clickhouse/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ type Serve struct {
}

func (s *Serve) Connect() error {
var err error
if s == nil || s.conn == nil {
err = errors.New("conn is null")
} else {
err = s.conn.Ping()
}
if err == nil {
return nil
}
switch s.DriveMode {
case 1:
s.conn, s.Error = s.DriveServe(s.Serve)
Expand All @@ -60,19 +69,15 @@ func (s *Serve) Close() error {
}

func (s *Serve) query(command string, args ...interface{}) (*sql.Rows, error) {
if s.conn == nil {
if err := s.Connect(); err != nil {
return nil, err
}
if err := s.Connect(); err != nil {
return nil, err
}
return s.conn.Query(command, args...)
}

func (s *Serve) exec(command string, args ...interface{}) (sql.Result, error) {
if s.conn == nil {
if err := s.Connect(); err != nil {
return nil, err
}
if err := s.Connect(); err != nil {
return nil, err
}
return s.conn.Exec(command, args...)
}
Expand Down
1 change: 0 additions & 1 deletion gsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ func (s *Serve) GetORM() *ORM {
case <-orm.chanComplete:
return
case <-time.After(time.Second * time.Duration(s.Timeout)):
orm.Close()
orm.Dispose()
}
}(c)
Expand Down
21 changes: 13 additions & 8 deletions mssqls/mssql.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ type Serve struct {
}

func (s *Serve) Connect() error {
var err error
if s == nil || s.conn == nil {
err = errors.New("conn is null")
} else {
err = s.conn.Ping()
}
if err == nil {
return nil
}
switch s.DriveMode {
case 1:
s.conn, s.Error = s.DriveServe(s.Serve)
Expand All @@ -60,19 +69,15 @@ func (s *Serve) Close() error {
}

func (s *Serve) query(command string, args ...interface{}) (*sql.Rows, error) {
if s.conn == nil {
if err := s.Connect(); err != nil {
return nil, err
}
if err := s.Connect(); err != nil {
return nil, err
}
return s.conn.Query(command, args...)
}

func (s *Serve) exec(command string, args ...interface{}) (sql.Result, error) {
if s.conn == nil {
if err := s.Connect(); err != nil {
return nil, err
}
if err := s.Connect(); err != nil {
return nil, err
}
return s.conn.Exec(command, args...)
}
Expand Down
21 changes: 13 additions & 8 deletions mysqls/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ type Serve struct {
}

func (s *Serve) Connect() error {
var err error
if s == nil || s.conn == nil {
err = errors.New("conn is null")
} else {
err = s.conn.Ping()
}
if err == nil {
return nil
}
switch s.DriveMode {
case 1:
s.conn, s.Error = s.DriveServe(s.Serve)
Expand All @@ -60,19 +69,15 @@ func (s *Serve) Close() error {
}

func (s *Serve) query(command string, args ...interface{}) (*sql.Rows, error) {
if s.conn == nil {
if err := s.Connect(); err != nil {
return nil, err
}
if err := s.Connect(); err != nil {
return nil, err
}
return s.conn.Query(command, args...)
}

func (s *Serve) exec(command string, args ...interface{}) (sql.Result, error) {
if s.conn == nil {
if err := s.Connect(); err != nil {
return nil, err
}
if err := s.Connect(); err != nil {
return nil, err
}
return s.conn.Exec(command, args...)
}
Expand Down

0 comments on commit 4a08532

Please sign in to comment.