Created
July 31, 2012 17:32
-
-
Save tobi/3218753 to your computer and use it in GitHub Desktop.
Error reading a datetime from
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 ( | |
_ "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) | |
} | |
} |
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
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