Skip to content

[Question] sqlite enable_load_extension #965

Open

Description

@zredb

For the SQLite database in SQLX, Do you support the enable_load_extension function? how can i load sqlite extension when i use Sqlx?

Activity

  1. changed the title [-]sqlite enable_load_extension[/-] [+][Question] sqlite enable_load_extension[/+] on Mar 26, 2025
  2. gurza commented on Apr 28, 2025

    @gurza

    You can access the underlying sqlite driver to enable and load extensions.

    Using mattn/go-sqlite3

    import (
            ....
    	"github.com/jmoiron/sqlx"
    	_ "github.com/mattn/go-sqlite3"
            "github.com/mattn/go-sqlite3"
    )

    you can do

    err = conn.Raw(func(driverConn interface{}) error {
    	sqliteConn, ok := driverConn.(*sqlite3.SQLiteConn)
    	if !ok {
    		return fmt.Errorf("failed to get SQLiteConn")
    	}
    	if err := sqliteConn.LoadExtension("/path/to/your/extension.so", ""); err != nil {
    		return fmt.Errorf("failed to load extension: %v", err)
    	}
    	return nil
    })
    if err != nil {
    	// handle error
    }

    @zredb does this approach suit you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions