Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

表中有值,也给客户端返回结果了,但是客户端没解析出来 #2

Closed
Penglq opened this issue Dec 13, 2021 · 2 comments · Fixed by #10
Closed

表中有值,也给客户端返回结果了,但是客户端没解析出来 #2

Penglq opened this issue Dec 13, 2021 · 2 comments · Fixed by #10

Comments

@Penglq
Copy link
Contributor

Penglq commented Dec 13, 2021

var v = &struct {
	EmpNo     int       `gorm:"emp_no"`
	BirthDate time.Time `gorm:"birth_date"`
	FirstName string    `gorm:"first_name"`
	LastName  string    `gorm:"last_name"`
	Gender    string    `gorm:"gender"`
	HireDate  time.Time `gorm:"hire_date"`
}{}

db, _ := sql.Open("mysql", "dksl:123456@tcp(127.0.0.1:13306)/employees?timeout=1s&readTimeout=1s&writeTimeout=1s&parseTime=true&loc=Local&charset=utf8mb4,utf8") //连接数据库
defer db.Close()

row := db.QueryRow(`SELECT emp_no FROM employees`)
if err := row.Scan(&v.EmpNo); err != nil {
	panic(err)
}
fmt.Println(v.EmpNo)

运行结果:
panic: sql: no rows in result set

image

What happened:
表中有值,也给客户端返回结果了,但是客户端没解析出来

What you expected to happen:

How to reproduce it (as minimally and precisely as possible):

Anything else we need to know?:

@dk-lockdown
Copy link
Contributor

db 啥版本啊

@Penglq
Copy link
Contributor Author

Penglq commented Dec 14, 2021

db 啥版本啊

5.7.34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants