[ANN] go-odbc: ODBC driver for Go

468 views
Skip to first unread message

Wei guangjing

unread,
Jan 18, 2011, 7:43:52 AM1/18/11
to golang-nuts
ODBC database driver for Go, Project URL: <https://github.com/weigj/go-odbc> .

Install:
    make install
    (note: windows need apply CL 3733046 <http://codereview.appspot.com/3733046/> for new cgo windows port.)

Example:

package main

import (
    "odbc"
)

func main() {
    conn, _ := odbc.Connect("DSN=dsn;UID=user;PWD=password")
    stmt, _ := conn.Prepare("select * from user where username = ?")
    stmt.Execute("admin")
    rows, _ := stmt.FetchAll()
    for i, row := range rows {
        println(i, row)
    }
    stmt.Close()
    conn.Close()
}

Tested on:
    SQL Server 2005 and Windows 7
    SQL Server 2005 and Ubuntu 10.4 (UnixODBC+FreeTDS)

Enjoy!

--
Wei guangjing

mattn

unread,
Jan 18, 2011, 8:00:07 AM1/18/11
to golan...@googlegroups.com
Awesome good. :)

Perhaps, you forgot call BindParam().

Wei guangjing

unread,
Jan 18, 2011, 8:05:21 AM1/18/11
to golan...@googlegroups.com
2011/1/18 mattn <mattn.jp@gmail.com>
Awesome good. :)

Perhaps, you forgot call BindParam().

Execute(params ...), Execute bind the params, so don't need call BindParam.

--
Wei guangjing

mattn

unread,
Jan 18, 2011, 8:50:31 AM1/18/11
to golan...@googlegroups.com
Oh sorry. X-(
And thanks for your great works.

Alex Angelini

unread,
Jan 18, 2011, 11:42:36 AM1/18/11
to golang-nuts
Awesome work,

Are there any plans to implement this with Thomas Lee's go-dbi

https://github.com/thomaslee/go-dbi

it would make for an excellent addition

brainman

unread,
Jan 18, 2011, 5:40:35 PM1/18/11
to golang-nuts
On Jan 18, 11:43 pm, Wei guangjing <vcc....@gmail.com> wrote:
> ODBC database driver for Go, Project URL: <https://github.com/weigj/go-odbc>
> .

Cool!

The only problem, I take it, you need mingw tools to build it. And I
don't think it is realistic for us to expect any Windows user to have
mingw installed. On the other hand, you can implement the same thing
by calling Windows odbc dlls directly, just as go syscall does.

Alex

peterGo

unread,
Jan 18, 2011, 6:09:28 PM1/18/11
to golang-nuts
Alex,

> I don't think it is realistic for us to expect any Windows user to have
> mingw installed.

Not true; I have MinGW installed on my Windows systems.

Peter

Joseph Poirier

unread,
Jan 18, 2011, 7:38:31 PM1/18/11
to peterGo, golang-nuts
On Tue, Jan 18, 2011 at 5:09 PM, peterGo <go.pe...@gmail.com> wrote:
> Alex,
>
>> I don't think it is realistic for us to expect any Windows user to have
>> mingw installed.
>
> Not true; I have MinGW installed on my Windows systems.
>
> Peter
>

IMHO, MinGW is a minor nit if it allows the use of CGO to easily build
lots of cool packages.

-joe

Mike Ramirez

unread,
Jan 18, 2011, 7:49:36 PM1/18/11
to golan...@googlegroups.com

On Tuesday, January 18, 2011 03:09:28 pm peterGo wrote:

> Alex,

>

> > I don't think it is realistic for us to expect any Windows user to have

> > mingw installed.

>

> Not true; I have MinGW installed on my Windows systems.

>

> Peter

>

One of the first things I install also.

--

Violence is the last refuge of the incompetent.

-- Salvor Hardin

Tom Lee

unread,
Jan 19, 2011, 6:31:19 AM1/19/11
to golan...@googlegroups.com

For the record, I'm happy to help with any efforts to implement a
"go-dbd-odbc"!

Cheers,
Tom

--
Tom Lee
http://tomlee.co

ph 0450 112 893


Wei guangjing

unread,
Jan 19, 2011, 9:14:09 AM1/19/11
to Tom Lee, golan...@googlegroups.com
2011/1/19 Tom Lee <goo...@tomlee.co>

On 19/01/11 03:42, Alex Angelini wrote:
Awesome work,

Are there any plans to implement this with Thomas Lee's go-dbi

https://github.com/thomaslee/go-dbi

it would make for an excellent addition

For the record, I'm happy to help with any efforts to implement a "go-dbd-odbc"!

Thanks Tom, I will look into it.

--
Wei guangjing

Tom Lee

unread,
Jan 19, 2011, 9:22:20 AM1/19/11
to golan...@googlegroups.com
If you're looking for an example, go-dbd-mysql is currently the most complete driver I know of.

https://github.com/thomaslee/go-dbd-mysql

Still room for improvement: if you find holes in the API, please let me know.
Reply all
Reply to author
Forward
0 new messages