Skip to content

Commit

Permalink
Modifying Handler.Open to retry opening urlstr with sqlite3 when it a…
Browse files Browse the repository at this point in the history
…ppears to be a local file
  • Loading branch information
Kenneth Shaw committed Mar 4, 2017
1 parent d2136f6 commit 3e0f981
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ various queries.
</p>

# TODO
* Fix --command/-c execution
* Better handling of local files (such as unix domain sockets) for Handler.Open
* All the various \\d* commands from `psql`
* SQL completion
9 changes: 8 additions & 1 deletion handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,14 @@ func (h *Handler) Open(urlstr string) error {

// parse dsn
h.u, err = dburl.Parse(urlstr)
if err != nil {
switch {
case err == dburl.ErrInvalidDatabaseScheme:
if _, err = os.Stat(urlstr); err == nil {
// it is a file, so reattempt to open it with sqlite3
return h.Open("sqlite3:" + urlstr)
}

case err != nil:
return err
}

Expand Down

0 comments on commit 3e0f981

Please sign in to comment.