FAQ
Hey!

How to put SQL rows into an array of string arrays? (/convert SQL result to
string matrix)

Thanks and best regards
Frank

--
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/groups/opt_out.

Search Discussions

  • Jackie Li at Mar 11, 2013 at 10:25 pm
    basically you have to create a slice of string and a slice of interface and
    put the pointer of the string to the interface.

    here is the snippet:
    cols, err := rows.Columns()
    if err != nil {
    log.Fatal(err)
    }
    fmt.Println(strings.Join(cols, "\t"))
    var result = make([]string, len(cols))
    var s = make([]interface{}, len(result))
    for i, _ := range result {
    s[i] = &result[i]
    }
    for rows.Next() {
    rows.Scan(s...)
    fmt.Println(strings.Join(result, "\t"))
    }
    rows.Close()

    also my full demo program is here: http://play.golang.org/p/UK7xoF3fb-


    On Mon, Mar 11, 2013 at 8:34 PM, Frank Blechschmidt wrote:

    Hey!

    How to put SQL rows into an array of string arrays? (/convert SQL result
    to string matrix)

    Thanks and best regards
    Frank

    --
    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/groups/opt_out.



    --
    Jackie

    --
    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/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMar 11, '13 at 8:34p
activeMar 11, '13 at 10:25p
posts2
users2
websitegolang.org

2 users in discussion

Frank Blechschmidt: 1 post Jackie Li: 1 post

People

Translate

site design / logo © 2022 Grokbase