IreneKnapp / direct-sqlite

MIT License
35 stars 54 forks source link

Add columnName (sqlite3_column_name) #26

Closed joeyadams closed 11 years ago

joeyadams commented 11 years ago

This adds support for sqlite3_column_name, which returns the name of a result column. Example:

> import Database.SQLite3
> conn <- open ":memory:"
> exec conn "CREATE TABLE foo (abc TEXT, d INT)"
> stmt <- prepare conn "SELECT *, randomblob(32) FROM foo"
> columnName stmt 0
Just "abc"
> columnName stmt 1
Just "d"
> columnName stmt 2
Just "randomblob(32)"
> columnName stmt 3
Nothing

@nurpax: This might be an easy way to provide column information for conversion errors in sqlite-simple (https://github.com/nurpax/sqlite-simple/issues/20).

nurpax commented 11 years ago

Very nice, thanks! I'll wait for this to be on hackage and then close out nurpax/sqlite-simple#20

IreneKnapp commented 11 years ago

Thanks for this! I'll do a hackage release in a few minutes when I have a real keyboard.