Questions tagged [go-sqlite3]
37 questions
3
votes
1 answer
sqlite3 in golang, foreign_keys pragma doesn't enforce keys
I have created an SQL file that loads into sqlite3 and creates a bunch of tables for me. In that sql file, I attempt to enforce foreign_keys with the pragma:
PRAGMA foreign_keys = on; -- also 1, true
When I load the sql file using -init it looks…

Omortis
- 1,334
- 19
- 44
3
votes
0 answers
How can I track a change to sqlite3 in golang?
everybody. I use the library "github.com/mattn/go-sqlite3" for working with the database.
I need to track the changes made to the database and after these changes are complete, execute some code.
I need to track the changes that another process…

user11433445
- 31
- 2
3
votes
1 answer
JSON fields from sqlite3
I have a json field in a sqlite3 collection. My schema looks like:
CREATE Table Animals(
id int,
sounds json,
name string
)
I understand the go-sqlite interface does not support the json datatype explicitly. However, my json is quite…

Mittenchops
- 18,633
- 33
- 128
- 246
2
votes
1 answer
Golang test hanging
I modified my app recently and found that tests started hanging. This the stripped down test code:
package app_test
…

kargirwar
- 536
- 2
- 7
- 19
2
votes
2 answers
How to fix "database is locked" when no concurrent threads are involved? golang, sqlite3
I'm running a list of sql files. The list of files comes from the same sqlite3 db that I'm going to execute sql against, hence there's only one db connection. If I don't kill the loop over sql files it will return "database is locked" error for…

Darian Hickman
- 853
- 10
- 26
2
votes
1 answer
How can I update my DB with a new version without interference with clients (golang / sqlite3)?
The database I am using is a global variable, initialized reading the file sql-repo.db:
const dbFile = "sql-repo.db"
var globalDB *LocalDB
type LocalDB struct {
Path string
handle *sql.DB
}
func InitSqlDB(dbDir string) error {
if…

matthieu
- 21
- 3
2
votes
1 answer
go-sqlite3 with journal_mode=WAL gives 'database is locked' error
In go, I open a sqlite3 database using the mattn/go-sqlite3 module. I set the database journalling mode to WAL immediately after opening using a PRAGMA journal_mode=WAL.
However, if I try to open the database from a second process while the first is…

Steve Hanov
- 11,316
- 16
- 62
- 69
2
votes
1 answer
Load SQLite3 database from virtual filesystem (afero)
Setting:
1) SQLite3 database file gets uploaded to a fileserver
2) Files get stored into virtual filesystem
3) I want to execute sql queries on that database
Currently I am using go-sqlite3 with a database file located in afero.
Question:
Is there…

Simon Frey
- 2,539
- 2
- 11
- 20
1
vote
1 answer
Golang with GORM - sqlite Error when trying to migrate
I am working on a Bot. For this purposes I have decided to use the sqlite DB and GORM as ORM. Right now i am working on a simple "Connection" file, that should connect with sqlite db (which is in the same folder as the Conection.go) and migrate the…

NightBottle
- 61
- 5
1
vote
1 answer
Using prepared statement for SQL queries in Go errors
I am trying to use a prepared statement for querying a sqlite file. This worked fine before, but I change the code to make it more unit testable. To do this, I started using prepared statements. However, I am getting an error of "No rows in result…

Anthony Quinn
- 45
- 5
1
vote
0 answers
Problems displaying image taken from sqlite3 database in vue.js
I'm building a social media-like web app, but I'm having trouble displaying images on the frontend.
For the realization I'm using openAPI , Golang for the backend, sqlte3 database, vue.js for the frontend.
For photos on the database I use a table…

fede14
- 11
- 2
1
vote
1 answer
Unable to save the data in two different table in golang using gorm
This is my code I'm not sure what went wrong the value which is in the user is getting updated in the user table properly but the address struct value is not storing the data in the address table
I want to save two users and address table with one…

Yogi
- 21
- 3
1
vote
1 answer
Execute the sqlite3 connector with golang in vscode. Met below error: collect2: error: ld returned 1 exit status
package main
import (
"database/sql"
"fmt"
"log"
"os"
_ "github.com/mattn/go-sqlite3"
)
type Users struct {
UserId, intUname string
}
func main() {
os.Remove("foo.db")
db, err := sql.Open("sqlite3", "foo.db")
…

marks
- 31
- 3
1
vote
0 answers
importing SQLite3 in GoLang
I want to import SQLite3 for my Project
import (
"database/sql"
_ "github.com/mattn/go-sqlite3"
)
But this Error happened:
could not import github.com/mattn/go-sqlite3 (no required module provides package "github.com/mattn/go-sqlite3")
I…

kasra rassi
- 11
- 1
1
vote
1 answer
Cross compilation from windows 10 to raspberry pi CGO_ENABLED = 1
I wish to compile for a raspberry pi from my windows machine (much faster).
Everything works if I use this command:
env GOOS=linux GOARCH=arm GOARM=5 go build src/*.go
However, I am using go-sqlite3 which apparently requires CGO_ENABLED = 1
Binary…

will.mendil
- 752
- 2
- 6
- 21