go-sqlite3 icon indicating copy to clipboard operation
go-sqlite3 copied to clipboard

How to use go-sqlite for android/iOS

Open NishchithSP opened this issue 5 years ago • 5 comments

I am creating a GO module which will be exported as library for Android/iOS apps (example: .aar for Android). I want to added database operation to this go module and using it in android and ios apps as both supports sqlite. I tried with examples provided. When i use "$go run [filename]" it creates db and runs without any issue. But when I add sqlite example code to my module and export it as '.aar' file (using gomobile bind) and include it in my android project and try to run. i get following error log

I/GoLog: "unable to open database file: no such file or directory": create table foo (id integer not null primary key, name text); delete from foo;

The issue was reported earlier ass well

https://github.com/golang/go/issues/18194#issue-193398369

but no proper solution posted and no information available. please let me know how to use go-sqlite in android devices

NishchithSP avatar Jun 04 '20 11:06 NishchithSP

What happens if you remove go-sqlite from the picture and simply do a os.Open() with the same file path that you pass to sql.Open() ?

marco-m avatar Jun 18 '20 17:06 marco-m

@marco-m I need sqlite for database operation. go-sqlite is working ok my PC (Desktop Application) but getting this error when i try the test program on mobile. I need go-sql working with gomobile

NishchithSP avatar Jun 19 '20 05:06 NishchithSP

What happens if you remove go-sqlite from the picture and simply do a os.Open() with the same file path that you pass to sql.Open() ?

@marco-m Also "os.Open()" cannot do any DB operations which is why I need sql

NishchithSP avatar Jun 22 '20 06:06 NishchithSP

@NishchithSP I think the intent was just to determine if the source of the error you are getting is actually SQLite itself, or just some file system issue, like the filepath being wrong, or you not having proper permissions.

rittneje avatar Jun 22 '20 12:06 rittneje