Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Other functions from modernc.org/sqlite #77

Closed
zakaria-chahboun opened this issue Jan 15, 2023 · 2 comments
Closed

Other functions from modernc.org/sqlite #77

zakaria-chahboun opened this issue Jan 15, 2023 · 2 comments

Comments

@zakaria-chahboun
Copy link

Hi! First of all Thank you for this project 馃尫

How i can benefit from other features with the modernc.org/sqlite driver?

For example, I can create a custom SQLite function by writing this:

import sqlite "modernc.org/sqlite"

func main() {
// register a new sqlite function! easily: (e.g SELECT new_id();)
sqlite.MustRegisterScalarFunction("new_id", 0, newID)

// ....

}

But this function (and others) doesn't appear in your driver.

Thanks 馃

@glebarez
Copy link
Owner

glebarez commented Jan 20, 2023

Sure,
you must directly use the underlying driver, which is a slight fork of modernc.org/sqlite

import (
   sqliteDriver "github.com/glebarez/go-sqlite"
  "github.com/glebarez/sqlite"
  "gorm.io/gorm"
)

// register a new sqlite function! easily: (e.g SELECT new_id();)
sqliteDriver.MustRegisterScalarFunction("new_id", 0, newID)

// create GORM DB
db, err := gorm.Open(sqlite.Open("sqlite.db"), &gorm.Config{})

@zakaria-chahboun
Copy link
Author

Thanks!

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

No branches or pull requests

2 participants