@Maciek maybe you could give
https://github.com/arnehormann/sqlinternals a
look, I told you about it here:
https://groups.google.com/forum/#!topic/golang-nuts/eZmWzURD-UoIt *should* be pretty easy to adapt it to PostgreSQL (that's still what
you're using, right?), I just lack the experience myself.
Have a look at the mysql package inside to see how it's used. The code is
(very) short.
I just crack open the database/sql wrapper struct and access the driver's
implementation of database/sql/driver.Rows, which will probably contain
everything you need.
I posted a concept to solve this in database/sql here:
https://groups.google.com/forum/#!searchin/golang-dev/database$2Fsql/golang-dev/0CM5MKbiQPs/3vRAFpvf_agJ
This is the issue I opened:
https://code.google.com/p/go/issues/detail?id=5606@Daniel I apologize for failing to deliver on my promise to review your
code.
I had a deeper look at it and it appears solid and thought through, but it
is too detailed for my taste.
I still think it's best to move more functionality surpassing the basic use
cases to the drivers.
Cheers,
Arne
Am Montag, 7. Juli 2014 06:04:21 UTC+2 schrieb Daniel Theophanes:
This has been discussed in the past, but I don't think this will happen in
"database/sql". I've started a new driver interface here:
http://godoc.org/bitbucket.org/kardianos/rdb#ColumnThe design is intended to work well in frameworks that need this
information. For my use case it is working well, though I only have one
fully operational driver right now. I hope to add a PG driver soon. If you
are interested, I'd love to also get an Oracle driver using their
(gigantic) C DLL. Feedback or design suggestions welcome.
-Daniel
On Sunday, July 6, 2014 2:34:04 PM UTC-7, Maciek Sakrejda wrote:I'm trying to write a tool that processes the results of arbitrary
user-supplied database queries using a database/sql driver. Unfortunately,
that makes calling Rows.Scan() problematic, because I don't know what I
should be scanning into. I'm sure this is atypical, but it does
happen--consider a database admin tool that needs to run user-supplied
queries and display results. Other database APIs offer some way of getting
type information [1], but as far as I can tell, in database/sql, I only
have Rows.Columns(), which only gives me the column names. Could a
Rows.ColumnTypes() be added? What could it return? It seems the most
flexible implementation would have to return some identifier of the
internal database type, rather than the expected Go type (since otherwise
this clashes with the Scanner design).
[1]: e.g.,
http://docs.oracle.com/javase/7/docs/api/java/sql/ResultSetMetaData.html#getColumnClassName(int) --
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit
https://groups.google.com/d/optout.