Pure Go Oracle Driver?

3,683 views
Skip to first unread message

oldCoderException

unread,
Jul 20, 2015, 1:50:24 PM7/20/15
to golan...@googlegroups.com
Hi everyone,

I pretty much know the answer to this (no) since I couldn't find any, but in the off-chance that somebody has something "in the works" I thought I'd pose the question.

Are there any pure Go database drivers for Oracle?  I usually don't use Oracle, but have a project where I have no choice but to read data from an Oracle database.  I guess I'm a "purist" in that I really don't like using C libraries with Go and much prefer pure Go solutions, but it seems that all the Oracle drivers use CGO.

thanks in advance,
Paul

Daniel Theophanes

unread,
Jul 20, 2015, 2:01:50 PM7/20/15
to golan...@googlegroups.com
This is a golang-nuts question.

Answer: no. I don't think there is any official specification and they change the protocol from release to release. At your own risk you could try to implement it from this:
http://www.pythian.com/blog/repost-oracle-protocol/  But I don't know what the legal ramifications would be.

brainman

unread,
Jul 20, 2015, 8:35:43 PM7/20/15
to golan...@googlegroups.com
Are you running on windows? Can you use odbc to access your database?

If your both answers are "yes", then you can try my github.com/alexbrainman/odbc driver. I only use it for ms sql, but I don't see why it wouldn't work for any other odbc driver.

Alex

Paul Stead

unread,
Jul 20, 2015, 9:00:19 PM7/20/15
to brainman, golang-nuts
Thanks Alex,  I should have mentioned the OS.  We're running linux, Ubuntu 14.04.  

cheers,


--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/RNC0JwZDQtw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tamás Gulácsi

unread,
Jul 21, 2015, 12:43:23 AM7/21/15
to golan...@googlegroups.com
Then you're out of luck, Oracle never puvlished their proprietary protocol.

Maybe you could create a separate minimal Oracle-facing app, and communicate with it (see natefinch/pie). That way your main app wouldn't be "polluted" with cgo.

brainman

unread,
Jul 21, 2015, 1:04:44 AM7/21/15
to golan...@googlegroups.com
On Tuesday, 21 July 2015 14:43:23 UTC+10, Tamás Gulácsi wrote:
> ... Maybe you could create a separate minimal Oracle-facing app, and communicate with it ...

I always wandered if it is possible to create golang.org/pkg/database/sql/driver "network proxy". Instead of "importing" your database driver, you connect to the proxy (running on different computer / os) and your database code still works. I never got around to actually spending time building it. Maybe it won't work.

Alex

Daniel Theophanes

unread,
Jul 21, 2015, 1:20:07 AM7/21/15
to golan...@googlegroups.com
Funny that you mention that. A few years ago I did something similar. I made a C# module connect over named pipes to a running go service that tunnelled a connection to a defined remote endpoint, data transferred as json I think. The remote end point then directly queried the MS SQL database using Alex's odbc package and returned the result to the iIS module over the waiting named pipe.

The real trick I've dreamed about is to make a SQL transpiler that translates a common SQL dialect to any other dialect and directly communicates with the servers. 

Tamás Gulácsi

unread,
Jul 21, 2015, 2:51:23 AM7/21/15
to golan...@googlegroups.com
database/sql requires very few, a "minimal viable product" is achievable in a few hundred libes of code.

The hard thing is the full OCI support, with LOBs and calling stored procedures returning multiple cursors...

Robert Johnstone

unread,
Jul 21, 2015, 2:33:25 PM7/21/15
to golan...@googlegroups.com, alex.b...@gmail.com
You can get ODBC support for linux as well.  I've used ODBC with success in Go, but not against an Oracle database.  There are at least two ODBC wrappers that support both Windows and unixODBC.

Regards,

Robert

brainman

unread,
Jul 22, 2015, 1:36:34 AM7/22/15
to golang-nuts
On Wednesday, 22 July 2015 04:33:25 UTC+10, Robert Johnstone wrote:
> You can get ODBC support for linux as well. I've used ODBC with success in Go, ...

Sure. I use freetds on linux to access ms sql server myself. But oldCoderException is looking for "non-cgo" solution. So that makes solutions like unixODBC unacceptable for oldCoderException.

Alex

Rich

unread,
Jul 22, 2015, 3:56:00 PM7/22/15
to golang-nuts
If you're going to be using Linux, I've had no problems with the CGO version of the oracle driver developed by Mattn: https://github.com/mattn/go-oci8.  I had a situation where we wanted a tool that could be used from the command line with the passwords and connection information hard coded, so the user could just run a command like: sqlrun -l dbuser -q "select * from database" and have the results look decent.  The -l is the login the -q is the query. Passwords and other information required to make the connection are hidden and read only.  I am not a programmer by trade, I am a Linux sysadmin and If I can write a tool like that using Mattn's Oracle -- anyone can.  The only reason I could see to want a Go only program would be to port that to a server that didn't have the client installed, or if you're cross compiling.   That being said I'll offer my code after I clean out the proprietary stuff if you want it.  Might help in getting your app written.

Thanks, Rich

Paul Stead

unread,
Jul 22, 2015, 4:10:37 PM7/22/15
to Rich, golang-nuts
Much appreciated Rich,

As you astutely hinted, we're deploying to a server that doesn't have the oracle client installed, and don't want to get into more "disparate bits" that we don't fully understand for one tiny bit of a large application.  Anyway, we've decided that, since we're using a microservice oriented design, that simply this one little microservice will have to be done in Java.  Most of our established code base over the last 15+ years is Java anyway so it's not at all unusual for us.  We're just transitioning new dev to Go.  As mentioned, Oracle isn't our "shtick" at all.  Our own stuff all uses PostgreSQL, for which we are now using lib/pq, and with great success I might add.  Since this one interface isn't our database however, we don't have a choice, and will simply do this bit in Java, which we've done many times before.

Thank you all for your input and discussion.  Maybe Oracle will get on board some day and do an Oracle Go driver (yeah... right).  ;)

cheers,

--

Samy Sultan

unread,
Sep 15, 2020, 4:07:11 PM9/15/20
to golang-nuts
you can see my project go-ora it is a pure go oracle client

Luis Fernando Gaido

unread,
Jul 29, 2021, 12:48:47 AM7/29/21
to golang-nuts

This was the best thing that happened to me in all these years working with Golang and Oracle.
Reply all
Reply to author
Forward
0 new messages