volatiletech / sqlboiler-sqlite3

sqlite3 driver for sqlboiler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unable to get table names: disk I/O error

lucaspiller opened this issue · comments

I'm getting this error when trying to generate the models. Not exactly sure what's going on, as everything looks fine to me. I've tried removing the packages (including go-sqlite3) and reinstalling but it doesn't make any difference.

$ go get -u github.com/volatiletech/sqlboiler

$ go get -u github.com/volatiletech/sqlboiler-sqlite3 

$ cat sqlboiler.toml
[sqlite3]
dbname = "/home/luca/Pictures/pixels.sqlite3"

$ sqlboiler sqlite3 --wipe -d                                                                                                                                                                      
using driver: /home/luca/src/go/bin/sqlboiler-sqlite3                                                                                                                                                                                   
unable to get table names: disk I/O error                                                                                                                                                                                               
{"config":{"driver_name":"sqlite3","driver_config":{"blacklist":null,"dbname":"/home/luca/Pictures/pixels.sqlite3","whitelist":null},"pkg_name":"models","out_folder":"models","debug":true,"wipe":true,"struct_tag_casing":"snake","imp
orts":{"all":{"Standard":["\"database/sql\"","\"fmt\"","\"reflect\"","\"strings\"","\"sync\"","\"time\""],"ThirdParty":["\"github.com/pkg/errors\"","\"github.com/volatiletech/sqlboiler/boil\"","\"github.com/volatiletech/sqlboiler/qu
eries\"","\"github.com/volatiletech/sqlboiler/queries/qm\"","\"github.com/volatiletech/sqlboiler/queries/qmhelper\"","\"github.com/volatiletech/sqlboiler/strmangle\""]},"test":{"Standard":["\"bytes\"","\"reflect\"","\"testing\""],"T
hirdParty":["\"github.com/volatiletech/sqlboiler/boil\"","\"github.com/volatiletech/sqlboiler/queries\"","\"github.com/volatiletech/sqlboiler/randomize\"","\"github.com/volatiletech/sqlboiler/strmangle\""]},"singleton":{"boil_querie
s":{"Standard":null,"ThirdParty":["\"github.com/volatiletech/sqlboiler/drivers\"","\"github.com/volatiletech/sqlboiler/queries\"","\"github.com/volatiletech/sqlboiler/queries/qm\""]},"boil_types":{"Standard":["\"strconv\""],"ThirdPa
rty":["\"github.com/pkg/errors\"","\"github.com/volatiletech/sqlboiler/boil\"","\"github.com/volatiletech/sqlboiler/strmangle\""]}},"test_singleton":{"boil_main_test":{"Standard":["\"database/sql\"","\"flag\"","\"fmt\"","\"math/rand
\"","\"os\"","\"path/filepath\"","\"strings\"","\"testing\"","\"time\""],"ThirdParty":["\"github.com/spf13/viper\"","\"github.com/volatiletech/sqlboiler/boil\""]},"boil_queries_test":{"Standard":["\"bytes\"","\"fmt\"","\"io\"","\"io
/ioutil\"","\"math/rand\"","\"regexp\""],"ThirdParty":["\"github.com/volatiletech/sqlboiler/boil\""]},"boil_suites_test":{"Standard":["\"testing\""],"ThirdParty":null}}},"aliases":{}},"driver_config":{"blacklist":null,"dbname":"/hom
e/luca/Pictures/pixels.sqlite3","whitelist":null},"schema":"","dialect":{"lq":0,"rq":0,"use_index_placeholders":false,"use_last_insert_id":false,"use_schema":false,"use_default_keyword":false,"use_auto_columns":false,"use_top_clause
":false,"use_output_clause":false,"use_case_when_exists_clause":false},"tables":null,"templates":null}                                                                                                                                  
Error: exit status 1                                                                                                                                                                                                                    
driver (/home/luca/src/go/bin/sqlboiler-sqlite3) exited non-zero                                                                                                                                                                        
github.com/volatiletech/sqlboiler/drivers.execute
/home/luca/src/go/pkg/mod/github.com/volatiletech/sqlboiler@v3.4.0+incompatible/drivers/binary_driver.go:73

I've tried deleting and recreating the database in case anything is messed up there, but it looks fine:

$ sqlite3 /home/luca/Pictures/pixels.sqlite3 .dump
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE migrations(
                                version INT NOT NULL PRIMARY KEY,
                                migrated_at INTEGER NOT NULL
                        );
INSERT INTO migrations VALUES(1,1560773272);
CREATE TABLE photos (
                                id UUID NOT NULL PRIMARY KEY,
                                path TEXT NOT NULL,
                                exif_parsed_at INTEGER,
                                taken_at TIMESTAMP,
                                width INTEGER,
                                height INTEGER,
                                camera_make TEXT,
                                camera_model TEXT,
                                f_number REAL,
                                exposure_time_string TEXT,
                                exposure_time REAL,
                                focal_length REAL,
                                iso INTEGER,
                                orientation INTEGER,
                                latitude REAL,
                                longitude REAL,
                                created_at INTEGER NOT NULL,
                                updated_at INTEGER NOT NULL,
                                UNIQUE(path)
                        );
COMMIT;

Versions:

$ sqlboiler --version
SQLBoiler v3.4.0

$ sqlite3 --version
3.28.0 2019-04-16 19:49:53 884b4b7e502b4e991677b53971277adfaf0a04a284f8e483e2553d0f83156b50

I tried to create your database and generate models from it and had no problems. Maybe you actually need to check your disk, it's also possible that you had the database opened in the terminal or something when you tried to generate models? Afaik there's file locking or something with sqlite3.

]> sqlboiler --version
SQLBoiler v3.4.0
]> sqlite3 --version
3.22.0 2018-01-22 18:45:57 0c55d179733b46d8d0ba4d88e01a25e10677046ee3da1d5b1581e86726f2alt1

@lucaspiller I ran into this too. Eventually I found that if the database was created using PRAGMA journal_mode=WAL; set (and there were telltale -shm and -wal files in the directory), things would fail with the error. Removing this pragma before my CREATEs and things worked fine.

Closing for staleness. Thanks for the workaround kalafut.