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

How to get rowid in sqlite database ? #122

Open
ibadi-id opened this issue Mar 3, 2022 · 1 comment
Open

How to get rowid in sqlite database ? #122

ibadi-id opened this issue Mar 3, 2022 · 1 comment

Comments

@ibadi-id
Copy link

ibadi-id commented Mar 3, 2022

I need to retrieve row id from sqlite table, my query like so :

SELECT(table.Account.AllColumns).FROM(table.Account)

I can't get the row id from the table, maybe you have a solution?

I think in generating tables and models, we should add:

Rowid int

@go-jet
Copy link
Owner

go-jet commented Mar 3, 2022

Hi @ibadi-id. Check raw expression and faq.

stmt := SELECT(
        Raw("rowid").AS("row_id"),
        Account.AllColumns,
    ).FROM(Account)

var dest struct {
    RowID int64
    model.Account
}

err := stmt.Query(db, &dest)

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

No branches or pull requests

2 participants