Add driver.Connector implementation for SQLite (#1001) #1340
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of Changes
This pull request implements the
database/sql/driver.Connector
interface forgo-sqlite3
by adding aSQLiteConnector
struct and aNewConnector
method, addressing issue #1001. The implementation enables configuring SQLite connections without global driver registration viasql.Register
, simplifying application and test setups by avoiding driver name conflicts. It supports context-aware connections and custom DSN options (e.g.,_journal_mode
,_busy_timeout
), aligning with Go 1.10+ practices. Additionally, this PR corrects unintended file mode changes forsqlite3.go
andsqlite3_test.go
from100755
(executable) to100644
(non-executable) that occurred in the initial commit. Tests verify connector functionality, and documentation has been updated.Key Changes
Added
SQLiteConnector
insqlite3.go
:driver.Connector
withConnect
andDriver
methods.NewConnector
method toSQLiteDriver
for creating connectors.Options
map.Added tests in
sqlite3_connector_test.go
:NewConnector
,Connect
, and basic database operations (create, insert, select)._journal_mode=WAL
).Driver
method returns the correctSQLiteDriver
.Updated existing tests in
sqlite3_test.go
:sql.Open
withsql.OpenDB
usingSQLiteConnector
where possible to avoid global driver registration.Fixed file modes:
sqlite3.go
andsqlite3_test.go
to100644
(non-executable) to correct unintended executable mode (100755
).