Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE customer (
- id SERIAL PRIMARY KEY,
- name character varying(30) NOT NULL,
- created_at timestamp with time zone NOT NULL DEFAULT NOW()
- );
- conn, err := pgx.Connect(context.Background(), os.Getenv("postgres://user:@127.0.0.1:5432/dbname"))
- if err != nil {
- fmt.Fprintf(os.Stderr, "Unable to connection to database: %vn", err)
- os.Exit(1)
- }
- defer conn.Close(context.Background())
- _, err = conn.Exec(context.Background(), "INSERT INTO customer(name) values($1)", "something")
- if err != nil {
- log.Fatal(err)
- }
- 2019/08/14 09:24:26 ERROR: null value in column "created_at" violates not-null constraint (SQLSTATE 23502)
- exit status 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement