diff options
author | Alexander Neonxp Kiryukhin <i@neonxp.ru> | 2024-10-06 17:04:37 +0300 |
---|---|---|
committer | Alexander Neonxp Kiryukhin <i@neonxp.ru> | 2024-10-06 17:04:37 +0300 |
commit | 6160b4fdc5f37e4ceaa6b3c5acc855f466049d61 (patch) | |
tree | b6e41f9cad22515a61cc50b0a82d98ee55e0c3e3 /pkg/db/db.go | |
parent | 81b13617c4d0ca68afb181d1105386f0c339864d (diff) |
Первая версия
Diffstat (limited to 'pkg/db/db.go')
-rw-r--r-- | pkg/db/db.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/pkg/db/db.go b/pkg/db/db.go new file mode 100644 index 0000000..8b7c47c --- /dev/null +++ b/pkg/db/db.go @@ -0,0 +1,18 @@ +package db + +import ( + "database/sql" + + "github.com/uptrace/bun" + "github.com/uptrace/bun/dialect/pgdialect" + "github.com/uptrace/bun/driver/pgdriver" +) + +// dsn := "postgres://postgres:@localhost:5432/test?sslmode=disable" +// dsn := "unix://user:pass@dbname/var/run/postgresql/.s.PGSQL.5432" + +func New(config *Config) *bun.DB { + sqldb := sql.OpenDB(pgdriver.NewConnector(pgdriver.WithDSN(config.DSN))) + + return bun.NewDB(sqldb, pgdialect.New()) +} |