mattn/go-sqlite3

How to run a dot command like ".import file.csv test"?

evt opened this issue · 3 comments

evt commented
_, err = db.Exec(".import epf.csv video")
if err != nil {
    log.Fatal(err)
}

Error: near ".": syntax error

In my experience, those commands are not supported by this library. .schema will result in the same thing.

mattn commented

it's a feature of sqlite3 command not this library. if you want, you need to implement the feature or call sqlite3 command.

exec.Command("sqlite3", "-cmd", ".import sample.csv ").CaptureOutput()

Is it possible to get support for dot command future like

r, err = db.Exec(".tables")
if err != nil {
log.Fatal(err)
}

or

r, err = db.Query(".schema")
if err != nil {
log.Fatal(err)
}