Note that there are some explanatory texts on larger screens.

plurals
  1. POGo 1.1.1 and ODBC with MSSQL
    primarykey
    data
    text
    <p>Currently have <strong>FreeTDS 0.92.4</strong> / <strong>unixODBC 2.3.1</strong> up and running, connecting with a MSSQL server and able to execute queries etc.</p> <p>I've found this list of ODBC implementations for Go, and have tried the two in bold:</p> <ul> <li>BenoyRNair <a href="https://github.com/BenoyRNair/godbc/" rel="nofollow">https://github.com/BenoyRNair/godbc/</a> </li> <li>Wei guangjing <a href="https://github.com/weigj/go-odbc" rel="nofollow">https://github.com/weigj/go-odbc</a> </li> <li><strong>Mark Severson</strong> <a href="https://bitbucket.org/miquella/mgodbc" rel="nofollow">https://bitbucket.org/miquella/mgodbc</a> </li> <li>Luke Mauldin <a href="https://github.com/LukeMauldin/lodbc" rel="nofollow">https://github.com/LukeMauldin/lodbc</a> </li> <li>Robert Johnstone <a href="https://bitbucket.org/rj/odbc3-go/" rel="nofollow">https://bitbucket.org/rj/odbc3-go/</a> </li> <li><strong>brainman</strong> <a href="http://code.google.com/p/odbc/" rel="nofollow">http://code.google.com/p/odbc/</a> </li> </ul> <hr> <h1>mgodbc</h1> <p>I'm getting a bunch of deprecation warnings <em>(looking at the headers they're deprecated for OSX 10.8 and later)</em>:</p> <pre><code>cc1: warnings being treated as errors mgodbc.go: In function 'mSQLColAttribute': mgodbc.go:31: warning: 'SQLColAttributeW' is deprecated (declared at /usr/include/sqlucode.h:128) mgodbc.go: At top level: mgodbc.go:44: warning: 'SQLDisconnect' is deprecated (declared at /usr/include/sql.h:896) mgodbc.go:51: warning: 'SQLGetDiagRecW' is deprecated (declared at /usr/include/sqlucode.h:233) mgodbc.go:62: warning: 'SQLGetInfoW' is deprecated (declared at /usr/include/sqlucode.h:273) mgodbc.go:67: warning: 'SQLBindParameter' is deprecated (declared at /usr/include/sqlext.h:2519) mgodbc.go:70: warning: 'SQLDriverConnectW' is deprecated (declared at /usr/include/sqlucode.h:336) mgodbc.go:73: warning: 'SQLSetEnvAttr' is deprecated (declared at /usr/include/sql.h:1120) mgodbc.go:74: warning: 'SQLFreeHandle' is deprecated (declared at /usr/include/sql.h:942) mgodbc.go:75: warning: 'SQLSetConnectAttrW' is deprecated (declared at /usr/include/sqlucode.h:245) mgodbc.go:78: warning: 'SQLGetDiagFieldW' is deprecated (declared at /usr/include/sqlucode.h:223) mgodbc.go:82: warning: 'SQLRowCount' is deprecated (declared at /usr/include/sql.h:1076) mgodbc.go:98: warning: 'SQLGetData' is deprecated (declared at /usr/include/sql.h:975) mgodbc.go:99: warning: 'SQLEndTran' is deprecated (declared at /usr/include/sql.h:902) mgodbc.go:102: warning: 'SQLCloseCursor' is deprecated (declared at /usr/include/sql.h:831) mgodbc.go:103: warning: 'SQLPrepareW' is deprecated (declared at /usr/include/sqlucode.h:239) mgodbc.go:107: warning: 'SQLNumResultCols' is deprecated (declared at /usr/include/sql.h:1058) mgodbc.go:113: warning: 'SQLAllocHandle' is deprecated (declared at /usr/include/sql.h:799) mgodbc.go:114: warning: 'SQLExecute' is deprecated (declared at /usr/include/sql.h:921) mgodbc.go:115: warning: 'SQLFetch' is deprecated (declared at /usr/include/sql.h:924) mgodbc.go:119: warning: 'SQLNumParams' is deprecated (declared at /usr/include/sqlext.h:2448) </code></pre> <h3>Update</h3> <p>Following a suggestion from mac01021, from go-nuts irc, I've added</p> <pre><code>#pragma GCC diagnostic ignored "-Wdeprecated-declarations" </code></pre> <p>This gets rid of the deprecation warnings, but still doesn't build against the included iODBC of OS X</p> <p>Replacing the above line with:</p> <pre><code>#cgo darwin CFLAGS: -I/opt/local/include </code></pre> <p>and voila, mgodbc builds now <em>(using the installed unixODBC)</em><br> although now a nice little segfault occurs upon import =(</p> <hr> <h1>odbc</h1> <p>I'm getting build errors:</p> <pre><code># code.google.com/p/odbc/api api/api.go:13: undefined: SQLSMALLINT api/api.go:14: undefined: SQLUSMALLINT api/api.go:15: undefined: SQLUSMALLINT api/api.go:19: undefined: SQLSMALLINT api/api.go:20: undefined: SQLUSMALLINT api/api.go:21: undefined: SQLUSMALLINT api/api.go:22: undefined: SQLUSMALLINT api/api.go:23: undefined: SQLUSMALLINT api/api.go:24: undefined: SQLUSMALLINT api/api.go:25: undefined: SQLUINTEGER api/api.go:25: too many errors </code></pre> <h3>Update</h3> <p>Thanks @alex for the <code>cgo</code> info. I've modified <code>api_unix.go</code> with the below </p> <pre><code>// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build linux darwin // +build cgo package api // #cgo linux LDFLAGS: -lodbc // #cgo darwin LDFLAGS: -lodbc // #cgo darwin CFLAGS: -I /opt/local/include // #include &lt;sql.h&gt; // #include &lt;sqlext.h&gt; import "C" </code></pre> <p>The iODBC included with OS X has some things that are listed as deprecated <em>(and I've had better luck with unixODBC in the past)</em> </p> <p>I've added the <code>-I /opt/local/include</code> to the CFLAGS to, hopefully, point to the unixODBC headers, and not the ones included by Apple (which have the deprecation warnings etc.)</p> <p>Running <code># go build -x</code> gives me: </p> <pre><code>WORK=/var/folders/z2/k9vxn7gn6395vb3y2qc7_1040000gn/T/go-build784364461 mkdir -p $WORK/code.google.com/p/odbc/api/_obj/ mkdir -p $WORK/code.google.com/p/odbc/ cd /Users/jr/Development/go/src/code.google.com/p/odbc/api /usr/local/go/pkg/tool/darwin_amd64/cgo -objdir $WORK/code.google.com/p/odbc/api/_obj/ -- -I /opt/local/include -I $WORK/code.google.com/p/odbc/api/_obj/ api_unix.go /usr/local/go/pkg/tool/darwin_amd64/6c -F -V -w -I $WORK/code.google.com/p/odbc/api/_obj/ -I /usr/local/go/pkg/darwin_amd64 -o $WORK/code.google.com/p/odbc/api/_obj/_cgo_defun.6 -D GOOS_darwin -D GOARCH_amd64 $WORK/code.google.com/p/odbc/api/_obj/_cgo_defun.c gcc -I . -g -O2 -fPIC -m64 -pthread -fno-common -print-libgcc-file-name gcc -I . -g -O2 -fPIC -m64 -pthread -fno-common -I /opt/local/include -I $WORK/code.google.com/p/odbc/api/_obj/ -o $WORK/code.google.com/p/odbc/api/_obj/_cgo_main.o -c $WORK/code.google.com/p/odbc/api/_obj/_cgo_main.c gcc -I . -g -O2 -fPIC -m64 -pthread -fno-common -I /opt/local/include -I $WORK/code.google.com/p/odbc/api/_obj/ -o $WORK/code.google.com/p/odbc/api/_obj/_cgo_export.o -c $WORK/code.google.com/p/odbc/api/_obj/_cgo_export.c gcc -I . -g -O2 -fPIC -m64 -pthread -fno-common -I /opt/local/include -I $WORK/code.google.com/p/odbc/api/_obj/ -o $WORK/code.google.com/p/odbc/api/_obj/api_unix.cgo2.o -c $WORK/code.google.com/p/odbc/api/_obj/api_unix.cgo2.c gcc -I . -g -O2 -fPIC -m64 -pthread -fno-common -o $WORK/code.google.com/p/odbc/api/_obj/_cgo_.o $WORK/code.google.com/p/odbc/api/_obj/_cgo_main.o $WORK/code.google.com/p/odbc/api/_obj/_cgo_export.o $WORK/code.google.com/p/odbc/api/_obj/api_unix.cgo2.o -lodbc /usr/local/go/pkg/tool/darwin_amd64/cgo -objdir $WORK/code.google.com/p/odbc/api/_obj/ -dynimport $WORK/code.google.com/p/odbc/api/_obj/_cgo_.o -dynout $WORK/code.google.com/p/odbc/api/_obj/_cgo_import.c /usr/local/go/pkg/tool/darwin_amd64/6c -F -V -w -I $WORK/code.google.com/p/odbc/api/_obj/ -I /usr/local/go/pkg/darwin_amd64 -o $WORK/code.google.com/p/odbc/api/_obj/_cgo_import.6 -D GOOS_darwin -D GOARCH_amd64 $WORK/code.google.com/p/odbc/api/_obj/_cgo_import.c gcc -I . -g -O2 -fPIC -m64 -pthread -fno-common -o $WORK/code.google.com/p/odbc/api/_obj/_all.o $WORK/code.google.com/p/odbc/api/_obj/_cgo_export.o $WORK/code.google.com/p/odbc/api/_obj/api_unix.cgo2.o -Wl,-r -nostdlib /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/x86_64/libgcc.a /usr/local/go/pkg/tool/darwin_amd64/6g -o $WORK/code.google.com/p/odbc/api/_obj/_go_.6 -p code.google.com/p/odbc/api -D _/Users/jr/Development/go/src/code.google.com/p/odbc/api -I $WORK ./api.go $WORK/code.google.com/p/odbc/api/_obj/_cgo_gotypes.go $WORK/code.google.com/p/odbc/api/_obj/api_unix.cgo1.go /usr/local/go/pkg/tool/darwin_amd64/pack grcP $WORK $WORK/code.google.com/p/odbc/api.a $WORK/code.google.com/p/odbc/api/_obj/_go_.6 $WORK/code.google.com/p/odbc/api/_obj/_cgo_import.6 $WORK/code.google.com/p/odbc/api/_obj/_cgo_defun.6 $WORK/code.google.com/p/odbc/api/_obj/_all.o mkdir -p $WORK/code.google.com/p/odbc/_obj/ mkdir -p $WORK/code.google.com/p/ cd /Users/jr/Development/go/src/code.google.com/p/odbc /usr/local/go/pkg/tool/darwin_amd64/6g -o $WORK/code.google.com/p/odbc/_obj/_go_.6 -p code.google.com/p/odbc -complete -D _/Users/jr/Development/go/src/code.google.com/p/odbc -I $WORK -I /Users/jr/Development/go/pkg/darwin_amd64 ./column.go ./conn.go ./driver.go ./error.go ./handle.go ./odbcstmt.go ./param.go ./result.go ./rows.go ./stats.go ./stmt.go ./tx.go # code.google.com/p/odbc ./column.go:22: undefined: api.SQLGetData ./column.go:28: undefined: api.SQLBindCol ./column.go:47: undefined: api.SQLDescribeCol ./conn.go:20: undefined: api.SQLAllocHandle ./conn.go:28: undefined: api.SQLDriverConnect ./conn.go:39: undefined: api.SQLDisconnect ./driver.go:26: undefined: api.SQLAllocHandle ./driver.go:34: undefined: api.SQLSetEnvAttr ./driver.go:43: undefined: api.SQLSetEnvAttr ./driver.go:50: undefined: api.SQLSetEnvAttr ./driver.go:50: too many errors </code></pre> <p>It looks like the header path include is being passed correctly?<br> But still looks like things are not quite linking correctly? </p> <p><em>for <code>SQLGetData</code> I do see a matching definition from the <code>//sys SQLGetData...</code> comment from <code>api.go</code> within <code>/opt/local/include/sql.h</code></em> </p> <hr> <h1>UPDATE</h1> <p>The library mentioned at the top: </p> <blockquote> <p><strong>brainman</strong> <a href="http://code.google.com/p/odbc/" rel="nofollow">http://code.google.com/p/odbc/</a> </p> </blockquote> <p>Now works as a go-gettable package on OSX. There's even documentation to get you started with the odbc/tds portions.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload