ZhangZhihui's Blog  

 

package main

import (
    "context"
    "log"
    "os"

    "github.com/jackc/pgx/v5/pgxpool"
)

const DB_SOURCE = "postgresql://root:aaa@localhost:5432/zimple_bank?sslmode=disable"
func main() {
ctx := context.Background() connPool, err := pgxpool.New(ctx, DB_SOURCE)
    if err != nil {
        log.Fatal("cannot connect to db:", err)
    }

data, _ :
= os.ReadFile("db/schema/0000_init_schema.up.sql") connPool.Exec(ctx, string(data)) }

 

posted on 2023-12-10 22:19  ZhangZhihuiAAA  阅读(6)  评论(0编辑  收藏  举报