Skip to content

Add driver.Connector implementation for SQLite (#1001) #1340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ljluestc
Copy link

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 SQLiteConnector in sqlite3.go:

    • Implements driver.Connector with Connect and Driver methods.
    • Added NewConnector method to SQLiteDriver for creating connectors.
    • Supports context cancellation and DSN options via Options map.
  • 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 Driver method returns the correct SQLiteDriver.
  • Updated existing tests in sqlite3_test.go:

    • Replaced sql.Open with sql.OpenDB using SQLiteConnector where possible to avoid global driver registration.
  • Fixed file modes:

    • Restored sqlite3.go and sqlite3_test.go to 100644 (non-executable) to correct unintended executable mode (100755).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant