SHARE
TWEET

Untitled

a guest Aug 14th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE TABLE customer (
  2.     id SERIAL PRIMARY KEY,
  3.     name character varying(30) NOT NULL,
  4.     created_at timestamp with time zone NOT NULL DEFAULT NOW()
  5. );
  6.      
  7. conn, err := pgx.Connect(context.Background(), os.Getenv("postgres://user:@127.0.0.1:5432/dbname"))
  8.     if err != nil {
  9.         fmt.Fprintf(os.Stderr, "Unable to connection to database: %vn", err)
  10.         os.Exit(1)
  11.     }
  12.     defer conn.Close(context.Background())
  13.  
  14.     _, err = conn.Exec(context.Background(), "INSERT INTO customer(name) values($1)", "something")
  15.     if err != nil {
  16.         log.Fatal(err)
  17.     }
  18.      
  19. 2019/08/14 09:24:26 ERROR: null value in column "created_at" violates not-null constraint (SQLSTATE 23502)
  20. exit status 1
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top