Skip to content

Instantly share code, notes, and snippets.

@tobi
Created July 31, 2012 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobi/3218753 to your computer and use it in GitHub Desktop.
Save tobi/3218753 to your computer and use it in GitHub Desktop.
Error reading a datetime from
package main
import (
_ "code.google.com/p/go-mysql-driver/mysql"
"database/sql"
"log"
"time"
)
func main() {
db, err := sql.Open("mysql", "root:@tcp(localhost:3306)/stats_dev?charset=utf8&keepalive=1")
if err != nil {
log.Fatal(err)
}
row := db.QueryRow("SELECT timeslot FROM visits LIMIT 1")
var t time.Time
// returns err
// 2012/07/31 13:29:35 sql: Scan error on column index 0: unsupported driver -> Scan pair: []uint8 -> *time.Time
err = row.Scan(&t)
if err != nil {
log.Fatal(err)
}
}
CREATE TABLE `visits` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`timeslot` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
) ENGINE=MyISAM;
INSERT INTO `visits` (`timeslot`) VALUES ('2006-02-01 00:00');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment