@@ -27,7 +27,6 @@ const (
27
27
28
28
const (
29
29
sessionOptionKey = "session"
30
- connectionOptionKey = "connection"
31
30
udfPathOptionKey = "udfPath"
32
31
driverTypeKey = "driverType"
33
32
useUnsafeStringReaderKey = "useUnsafeStringReader"
@@ -137,13 +136,11 @@ func (e *execResult) RowsAffected() (int64, error) {
137
136
type queryHandle func (string , ... string ) (* chdbstable.LocalResult , error )
138
137
139
138
type connector struct {
140
- udfPath string
141
- driverType DriverType
142
- bufferSize int
143
- useUnsafe bool
144
- session * chdb.Session
145
- connection * chdb.Connection
146
- useConnection bool
139
+ udfPath string
140
+ driverType DriverType
141
+ bufferSize int
142
+ useUnsafe bool
143
+ session * chdb.Session
147
144
}
148
145
149
146
// Connect returns a connection to a database.
@@ -153,9 +150,7 @@ func (c *connector) Connect(ctx context.Context) (driver.Conn, error) {
153
150
}
154
151
cc := & conn {
155
152
udfPath : c .udfPath , session : c .session ,
156
- connection : c .connection ,
157
- useConnection : c .useConnection ,
158
- driverType : c .driverType , bufferSize : c .bufferSize ,
153
+ driverType : c .driverType , bufferSize : c .bufferSize ,
159
154
useUnsafe : c .useUnsafe ,
160
155
}
161
156
cc .SetupQueryFun ()
@@ -191,17 +186,6 @@ func NewConnect(opts map[string]string) (ret *connector, err error) {
191
186
return nil , err
192
187
}
193
188
}
194
- connectionStr , ok := opts [connectionOptionKey ]
195
- if ok {
196
- if ret .session != nil {
197
- return nil , fmt .Errorf ("could not use both session & connection. please use one of the two" )
198
- }
199
- ret .connection , err = chdb .NewConnection (connectionStr )
200
- if err != nil {
201
- return nil , err
202
- }
203
- ret .useConnection = true
204
- }
205
189
driverType , ok := opts [driverTypeKey ]
206
190
if ok {
207
191
ret .driverType = parseDriverType (driverType )
@@ -230,6 +214,12 @@ func NewConnect(opts map[string]string) (ret *connector, err error) {
230
214
if ok {
231
215
ret .udfPath = udfPath
232
216
}
217
+ if ret .session == nil {
218
+ ret .session , err = chdb .NewSession ()
219
+ if err != nil {
220
+ return nil , err
221
+ }
222
+ }
233
223
return
234
224
}
235
225
@@ -254,14 +244,13 @@ func (d Driver) OpenConnector(name string) (driver.Connector, error) {
254
244
}
255
245
256
246
type conn struct {
257
- udfPath string
258
- driverType DriverType
259
- bufferSize int
260
- useUnsafe bool
261
- useConnection bool
262
- session * chdb.Session
263
- connection * chdb.Connection
264
- QueryFun queryHandle
247
+ udfPath string
248
+ driverType DriverType
249
+ bufferSize int
250
+ useUnsafe bool
251
+ session * chdb.Session
252
+
253
+ QueryFun queryHandle
265
254
}
266
255
267
256
func prepareValues (values []driver.Value ) []driver.NamedValue {
@@ -285,9 +274,7 @@ func (c *conn) SetupQueryFun() {
285
274
if c .session != nil {
286
275
c .QueryFun = c .session .Query
287
276
}
288
- if c .connection != nil {
289
- c .QueryFun = c .connection .Query
290
- }
277
+
291
278
}
292
279
293
280
func (c * conn ) Query (query string , values []driver.Value ) (driver.Rows , error ) {
0 commit comments