mirror of
https://github.com/miniflux/v2.git
synced 2025-07-22 17:18:37 +00:00
Create database package (refactoring)
This commit is contained in:
parent
17054b396e
commit
cf03e0e338
30 changed files with 61 additions and 54 deletions
25
database/database.go
Normal file
25
database/database.go
Normal file
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2018 Frédéric Guillot. All rights reserved.
|
||||
// Use of this source code is governed by the Apache 2.0
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package database
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
// Postgresql driver import
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
||||
// NewConnectionPool configures the database connection pool.
|
||||
func NewConnectionPool(dsn string, minConnections, maxConnections int) (*sql.DB, error) {
|
||||
db, err := sql.Open("postgres", dsn)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
db.SetMaxOpenConns(maxConnections)
|
||||
db.SetMaxIdleConns(minConnections)
|
||||
|
||||
return db, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue