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.Connectorinterface forgo-sqlite3by adding aSQLiteConnectorstruct and aNewConnectormethod, 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.goandsqlite3_test.gofrom100755(executable) to100644(non-executable) that occurred in the initial commit. Tests verify connector functionality, and documentation has been updated.Key Changes
Added
SQLiteConnectorinsqlite3.go:driver.ConnectorwithConnectandDrivermethods.NewConnectormethod toSQLiteDriverfor creating connectors.Optionsmap.Added tests in
sqlite3_connector_test.go:NewConnector,Connect, and basic database operations (create, insert, select)._journal_mode=WAL).Drivermethod returns the correctSQLiteDriver.Updated existing tests in
sqlite3_test.go:sql.Openwithsql.OpenDBusingSQLiteConnectorwhere possible to avoid global driver registration.Fixed file modes:
sqlite3.goandsqlite3_test.goto100644(non-executable) to correct unintended executable mode (100755).