Skip to content

Commit

Permalink
Merge pull request #170 from bvp/master
Browse files Browse the repository at this point in the history
Initial PostgreSQL support
  • Loading branch information
RadhiFadlillah authored Sep 25, 2019
2 parents b315c48 + 4eb86d6 commit c2eee1d
Show file tree
Hide file tree
Showing 5 changed files with 655 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Shiori is a simple bookmarks manager written in Go language. Intended as a simpl
- Simple and clean command line interface.
- Simple and pretty web interface for those who don't want to use a command line app.
- Portable, thanks to its single binary format.
- Support sqlite3 and MySQL as its database.
- Support sqlite3, PostgreSQL and MySQL as its database.
- Where possible, by default `shiori` will parse the readable content and create an offline archive of the webpage.
- [BETA] [web extension](https://github.com/go-shiori/shiori-web-ext) support for Firefox and Chrome.

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/gofrs/uuid v3.2.0+incompatible
github.com/jmoiron/sqlx v1.2.0
github.com/julienschmidt/httprouter v1.2.0
github.com/lib/pq v1.1.1 // indirect
github.com/lib/pq v1.1.1
github.com/mattn/go-colorable v0.1.1 // indirect
github.com/mattn/go-isatty v0.0.7 // indirect
github.com/mattn/go-sqlite3 v1.10.0
Expand Down
12 changes: 11 additions & 1 deletion internal/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,17 @@ func openDatabase() (database.DB, error) {
connString := fmt.Sprintf("%s:%s@%s/%s", user, password, dbAddress, dbName)
return database.OpenMySQLDatabase(connString)
}

// Check if it uses PostgreSQL
if dbms, _ := os.LookupEnv("SHIORI_DBMS"); dbms == "postgresql" {
host, _ := os.LookupEnv("SHIORI_PG_HOST")
port, _ := os.LookupEnv("SHIORI_PG_PORT")
user, _ := os.LookupEnv("SHIORI_PG_USER")
password, _ := os.LookupEnv("SHIORI_PG_PASS")
dbName, _ := os.LookupEnv("SHIORI_PG_NAME")

connString := fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s sslmode=disable", host, port, user, password, dbName)
return database.OpenPGDatabase(connString)
}
// If not, just uses SQLite
dbPath := fp.Join(dataDir, "shiori.db")
return database.OpenSQLiteDatabase(dbPath)
Expand Down
Loading

0 comments on commit c2eee1d

Please sign in to comment.