create sevrer

This commit is contained in:
conzer 2024-12-07 17:45:46 -05:00
parent 088e83d6e6
commit 08f8693e8d
4 changed files with 112 additions and 0 deletions

19
db/db.go Normal file
View file

@ -0,0 +1,19 @@
package db
import (
"database/sql"
_ "github.com/lib/pq"
"log"
)
// Replace the "connStr" string with your DB connection username and password.
func ConnectDB() (*sql.DB, error) {
connStr := "user=username password=password123 dbname=cooldatabase sslmode=disable"
db, err := sql.Open("postgres", connStr)
if err != nil {
log.Fatalf("Failed to connect to the database: %v", err)
return nil, err
}
return db, nil
}