Created
July 6, 2016 18:25
-
-
Save dt/62b1f57f752216fedeefd1a380f1c484 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"database/sql" | |
"log" | |
"time" | |
_ "github.com/lib/pq" | |
) | |
func handle(res interface{}, err error) { | |
if err != nil { | |
panic(err) | |
} | |
log.Println(res) | |
} | |
func main() { | |
db, err := sql.Open("postgres", "postgresql://root@localhost:26257/d?sslmode=disable") | |
if err != nil { | |
panic(err) | |
} | |
handle(db.Exec("DROP DATABASE IF EXISTS d")) | |
handle(db.Exec("CREATE DATABASE d")) | |
handle(db.Exec("DROP TABLE IF EXISTS t")) | |
handle(db.Exec("CREATE TABLE t (t timestamp, tz timestamp with time zone)")) | |
handle(db.Exec("INSERT INTO t VALUES ($1, $2)", time.Time{}, time.Time{})) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment