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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade sqlite3 to the latest version. #34

Open
oSethoum opened this issue Oct 6, 2022 · 8 comments
Open

Upgrade sqlite3 to the latest version. #34

oSethoum opened this issue Oct 6, 2022 · 8 comments

Comments

@oSethoum
Copy link

oSethoum commented Oct 6, 2022

This package is using a the version 3.30.1 from sqlite3 which doesn't support RETURNING that a lot of orms use when creating new record in the database, I tried forking the package and using the upgrade script, but the pragma key is no longer working.
image

@ValentinMontmirail
Copy link

You may want to have a look at: https://github.com/ValentinMontmirail/go-sqlcipher
I just updated to SQLite 3.45.0 (This pre-release for now)

@oSethoum
Copy link
Author

@ValentinMontmirail Thank you, I will try it out soon and give you feedback.

@oSethoum
Copy link
Author

@ValentinMontmirail I cloned your repo locally and replaced the dependency, the issue is the database file doesn't get encrypted, am using it with ent like this

var Client *ent.Client

func Init() {
	client, err := ent.Open("sqlite3", "file:ent.sqlite?_key=secret&cache=shared&_fk=1")
	if err != nil {
		log.Fatalf("failed opening connection to sqlite: %v", err)
	}

	if err := client.Schema.Create(context.Background()); err != nil {
		log.Fatalf("failed creating schema resources: %v", err)
	}

	Client = client
}

the database file can be viewed.

image

@ValentinMontmirail
Copy link

That's odd. I will have a look. Thanks for the feedback !

@oSethoum
Copy link
Author

@ValentinMontmirail maybe am doing it wrong, if so, please provide an example that I can use.

@ValentinMontmirail
Copy link

Should be better now. Can you retry with github.com/ValentinMontmirail/go-sqlcipher v0.0.0-20231219102833-c47b144b2843 ?

@oSethoum
Copy link
Author

@ValentinMontmirail same thing, can you publish an example? maybe am doing something wrong.

@ValentinMontmirail
Copy link

small-Example.zip

You will find in attachment, a very small example where the *sql.DB object generated after encryption can be used by an ORM. Basically, it uses automatically-generated type-safe interfaces for your queries.

There is also a Docker image on alpine to make it run safely.

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