add scraping the torrent topics rss files
This commit is contained in:
24
internal/db/connector.go
Normal file
24
internal/db/connector.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func New() *sqlx.DB {
|
||||
drv := viper.GetString("db.driver")
|
||||
dsn := viper.GetString("db.data_source_name")
|
||||
|
||||
db, err := sqlx.Connect(drv, dsn)
|
||||
if err != nil {
|
||||
panic("Failed to connect to the database: " + err.Error())
|
||||
}
|
||||
|
||||
// Verify the connection to the database is still alive
|
||||
err = db.Ping()
|
||||
if err != nil {
|
||||
panic("Failed to ping the database: " + err.Error())
|
||||
}
|
||||
|
||||
return db
|
||||
}
|
||||
Reference in New Issue
Block a user