Skip to content

Support for SQLite's flexible data types? #395

@justinclift

Description

@justinclift

At present with go-sqlite3, there doesn't seem to be a way of retrieving the data type of a result set per row.

This is a problem when the data in a result set has different types in a column than declared by the table definition.

eg if a table says a column is of type (say) integer, and instead one of the rows has a (say) string, then retrieving the row barfs.

I think it's due to using sqlite3_column_decltype() in the DeclTypes() function, which only returns the table level declared column types.

At present I'm using gwenn's SQLite driver, as that has a per row (of the result set) function to retrieve the appropriate types:

    https://github.com/gwenn/gosqlite/blob/0f8d5237cc9841b45604b1c9e4ecbe78866bc6c7/stmt.go#L550-L555

@gwenn's focus these days is on Rust instead of Go, so it's probably a good idea (from my PoV) to see if this can be added in your driver which is much more widely used.

Note, I opened an issue ages ago with some background info for this on @gwenn's repo, if that helps: gwenn/gosqlite#5.

The use case is when working with user generated SQLite databases, for example:

    https://dbhub.io/justinclift/DB4S%20download%20stats.sqlite

Thoughts? 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions