Add driver.Connector implementation for SQLite (#1001)
Summary of Changes
This pull request implements the database/sql/driver.Connector interface for go-sqlite3 by adding a SQLiteConnector struct and a NewConnector method, addressing issue #1001. The implementation enables configuring SQLite connections without global driver registration via sql.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 for sqlite3.go and sqlite3_test.go from 100755 (executable) to 100644 (non-executable) that occurred in the initial commit. Tests verify connector functionality, and documentation has been updated.
Key Changes
-
Added
SQLiteConnectorinsqlite3.go:- Implements
driver.ConnectorwithConnectandDrivermethods. - Added
NewConnectormethod toSQLiteDriverfor creating connectors. - Supports context cancellation and DSN options via
Optionsmap.
- Implements
-
Added tests in
sqlite3_connector_test.go:- Verifies
NewConnector,Connect, and basic database operations (create, insert, select). - Tests context cancellation and custom options (e.g.,
_journal_mode=WAL). - Confirms
Drivermethod returns the correctSQLiteDriver.
- Verifies
-
Updated existing tests in
sqlite3_test.go:- Replaced
sql.Openwithsql.OpenDBusingSQLiteConnectorwhere possible to avoid global driver registration.
- Replaced
-
Fixed file modes:
- Restored
sqlite3.goandsqlite3_test.goto100644(non-executable) to correct unintended executable mode (100755).
- Restored