oracle官方驱动 go,go-oci8: oracle driver for go that using database/sql

go-oci8

go-oci8?status.svg

go-oci8.svg?branch=master

go-oci8

Description

Golang Oracle database driver conforming to the Go database/sql interface

Installation

Install Oracle full client or Instant Client:

Install a C/C++ compiler

Install pkg-config, edit your package config file oci8.pc (examples below), then set environment variable PKG_CONFIG_PATH to oci8.pc file location

(Or can use Go tag noPkgConfig then setup environment variables CGO_CFLAGS and CGO_LDFLAGS)

Go get with Go version 1.9 or higher

go get github.com/mattn/go-oci8

Try the simple select example:

If you have a build error it is normaly because of a misconfiguration, make sure to search close issues for help

oci8.pc Examples

Windows

prefix=/devel/target/XXXXXXXXXXXXXXXXXXXXXXXXXX

exec_prefix=${prefix}

libdir=C:/app/instantclient_12_2/sdk/oci/lib/msvc

includedir=C:/app/instantclient_12_2/sdk/include

glib_genmarshal=glib-genmarshal

gobject_query=gobject-query

glib_mkenums=glib-mkenums

Name: oci8

Description: oci8 library

Libs: -L${libdir} -loci

Cflags: -I${includedir}

Version: 12.2

Linux

prefix=/devel/target/XXXXXXXXXXXXXXXXXXXXXXXXXX

exec_prefix=${prefix}

libdir=/usr/lib/oracle/12.2/client64/lib

includedir=/usr/include/oracle/12.2/client64

glib_genmarshal=glib-genmarshal

gobject_query=gobject-query

glib_mkenums=glib-mkenums

Name: oci8

Description: oci8 library

Libs: -L${libdir} -lclntsh

Cflags: -I${includedir}

Version: 12.2

MacOs

Please install pkg-config with brew if not already present.

Download the instant client and the sdk and unpack it e.g. in your

Downloads folder and create therein a file names oci8.pc.

Please replace with your actual username.

prefixdir=/Users//Downloads/instantclient_12_2/

libdir=${prefixdir}

includedir=${prefixdir}/sdk/include

Name: OCI

Description: Oracle database driver

Version: 12.2

Libs: -L${libdir} -lclntsh

Cflags: -I${includedir}

You also have to set these environment variables

(e.g. permanently by adding them to your .bashrc)

export LD_LIBRARY_PATH=/Users//Downloads/instantclient_12_2

export PKG_CONFIG_PATH=/Users//Downloads/instantclient_12_2

SQL Examples

SQL examples can be found in the GoDoc reference:

And in _example:

Author

Yasuhiro Matsumoto (a.k.a mattn)

Special Thanks

Jamil Djadala

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值