String Int problem in SQLite

Hi,

I get the ID from sqlite3-database as int. I use the package from github.com/mattn/go-sqlite3

id, err := res.LastInsertId()

and then will set the ID and a other string to a new string.

t := strconv.FormatInt(int64(id), 10)
var ownDBfile string = "OrganisationDb" + t

The database shows the right entry, but i get the row with:

var id int
	var email string
	var admin int
	var master int
	var owndbfile string
	err = db.QueryRow("SELECT id, email, owndbfile, admin, master FROM user WHERE id=? AND active=1 AND del=0", uid).Scan(&id, &email, &admin, &master, &owndbfile)
	if err != nil {
		log.Println(err)
	}

and the log shows me the follow error:

 sql: Scan error on column index 2: converting driver.Value type []uint8 ("OrganisationDb1") to a int: invalid syntax

What the hell :slight_smile:

So uid is the string you built instead of the original ID?

okay my query have unnecessary reference and the uid is a consign function-call. But does not affect the error. :slight_smile:

Your scan parameters are in the wrong order. You’re scanning owndbfile (presumably "OrganisationDb1") into &admin which is a pointer to int.

1 Like

Ohhh yes my friend, of course this is a stupid mistake. I think I should go to bed!

Big THX

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.