This project is an integration test, testing various Go database drivers (for the database/sql package). To run these tests, in this directory, run: $ export GOPATH=$PWD ... ignoring your existing GOPATH. (This project imports all the 3rd party drivers here, to make things easier to track, and to enable local fixes while waiting for upstream.) Then: $ cd src/sqltest $ go test -v or, most of the time, skipping the annoyingly long tests: $ go test -v -short **************************************************************************** For MySQL: **************************************************************************** mysqladmin -uroot -proot create gosqltest To set set your MySQL user / password run: $ export GOSQLTEST_MYSQL_USER=user $ export GOSQLTEST_MYSQL_PASS=password **************************************************************************** For Postgres: (replacing "bradfitz" with $USER) **************************************************************************** root@bradfitzlap:/home/bradfitz# su - postgres postgres@bradfitzlap:~$ psql postgres=# create database gosqltest; CREATE DATABASE postgres=# CREATE USER bradfitz WITH ENCRYPTED PASSWORD 'gosqltest'; CREATE ROLE postgres=# GRANT ALL PRIVILEGES ON DATABASE gosqltest to bradfitz; GRANT **************************************************************************** For Oracle: (replacing "bradfitz" with $USER) **************************************************************************** root@bradfitzlap:/home/bradfitz# service oracle-xe start Iff you don't have a nice test database, then i.e.: sqlplus /nolog <<EOF CONN sys/sys AS SYSDBA CREATE DATABASE DB USER SYS IDENTIFIED BY SYS USER SYSTEM IDENTIFIED BY SYSTEM USER user IDENTIFIED BY password LOGFILE GROUP 1 ('/tmp/testdb-redo01.log') SIZE 20M MAXLOGFILES 5 MAXLOGMEMBERS 5 MAXLOGHISTORY 1 MAXDATAFILES 100 MAXINSTANCES 1 CHARACTER SET AL32UTF8 NATIONAL CHARACTER SET AL32UTF8 DATAFILE '/tmp/testdb-data01.dbf' EXTENT MANAGEMENT LOCAL DEFAULT TEMPORARY TABLESPACE temp DATAFILE '/tmp/testdb-temp01.dbf' SIZE 10M REUSE UNDO TABLESPACE undotbs DATAFILE '/tmp/testdb-undo01.dbf' SIZE 10M REUSE AUTOEXTEND ON NEXT 512K MAXSIZE 200M; CREATE TABLESPACE data LOGGING DATAFILE '/tmp/testdb-data01.dbf' SIZE 10M REUSE AUTOEXTEND ON NEXT 512K MAXSIZE 100M EXTENT MANAGEMENT LOCAL; CREATE TABLESPACE indx LOGGING DATAFILE '/tmp/testdb-indx01.dbf' SIZE 10M REUSE AUTOEXTEND ON NEXT 512K MAXSIZE 100M EXTENT MANAGEMENT LOCAL; EXIT EOF (More can be read at http://docs.oracle.com/cd/B10501_01/server.920/a96521/create.htm#1003614) To set set your Oracle user/password@DB run: $ export GOSQLTEST_ORACLE=user/password@db this will result connecting to database user/password@sid The corner case where the sid is a full DSN (with port and everything) is not fully managed: only port 1521 on localhost is checked for accepting connections. If you really need the full DSN support, please mail me!
test ALL the databases
Owner
Brad Fitzpatrick
Comments
-
Test fails with SQLite
With "github.com/mattn/go-sqlite3" driver: --- FAIL: TestPreparedStmt_SQLite (0.01 seconds) sql_test.go:306: Insert: database is locked
With "github.com/gwenn/gosqlite" driver (and sqlite3_log activated): === RUN TestPreparedStmt_SQLite LOG: Library used incorrectly, Dangling statement (not finalize): "INSERT INTO t (count) VALUES (?)" ... --- FAIL: TestPreparedStmt_SQLite (0.01 seconds) sql_test.go:306: Insert: The database file is locked: database is locked
I am using the weekly.2012-02-22 branch and SQLite 3.7.10.
The 'sel' Stmt locks the 'ins' Stmt because the 'sel' Stmt is "busy" (not reset/close).
A solution may be to Reset the 'sel' Stmt when '*Row#Scan' is called/finished but currently there is no such method in the Stmt interface. And the Stmt#Exec seems buggy: the connection is closed but not the associated Stmt!
Regards.
-
Enable Sourcegraph
I want to use Sourcegraph for go-sql-test code search, browsing, and usage examples. Can an admin enable Sourcegraph for this repository? Just go to https://sourcegraph.com/github.com/bradfitz/go-sql-test. (It should only take 30 seconds.)
Thank you!
-
Add go-libpq
This is a cgo-based Postgres driver with support for LISTEN/NOTIFY. I'm a little hesitant to put in this pull request since building this package depends on libpq being installed in a normal place, but I suppose you have the same issue with the included go-sqlite driver.
-
panic: runtime error: cgo argument has Go pointer to Go pointer
Hi,
go version go1.11.3 linux/amd64
goroutine 16 [running]: github.com/ibmdb/go_ibm_db/api.SQLBindCol.func1(0x4000100010001, 0xc00005c338, 0xc000000004, 0xc00005c318, 0x4edfa0) /home/rakhil/go/src/github.com/ibmdb/go_ibm_db/api/zapi_unix.go:26 +0x4c github.com/ibmdb/go_ibm_db/api.SQLBindCol(0x4000100010001, 0xc00005c338, 0x4, 0xc00005c318, 0x0) /home/rakhil/go/src/github.com/ibmdb/go_ibm_db/api/zapi_unix.go:26 +0x59 github.com/ibmdb/go_ibm_db.(*BufferLen).Bind(0xc00005c318, 0x10001, 0x0, 0x440004, 0xc00005c338, 0x4, 0x8, 0xc000010350) /home/rakhil/go/src/github.com/ibmdb/go_ibm_db/column.go:29 +0x62 github.com/ibmdb/go_ibm_db.(*BindableColumn).Bind(0xc00005c300, 0x10001, 0x0, 0xc00005c300, 0x0, 0x0) /home/rakhil/go/src/github.com/ibmdb/go_ibm_db/column.go:202 +0x6c github.com/ibmdb/go_ibm_db.(*ODBCStmt).BindColumns(0xc000096140, 0x7d9de0, 0x0) /home/rakhil/go/src/github.com/ibmdb/go_ibm_db/odbcstmt.go:148 +0x1eb github.com/ibmdb/go_ibm_db.(*Stmt).Query(0xc0000802d0, 0x7d9de0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0) /home/rakhil/go/src/github.com/ibmdb/go_ibm_db/stmt.go:93 +0xe5 database/sql.ctxDriverStmtQuery(0x513000, 0xc000016168, 0x513100, 0xc0000802d0, 0x7d9de0, 0x0, 0x0, 0x0, 0x0, 0x0, ...) /work/rakhil/go/src/database/sql/ctxutil.go:94 +0x16b database/sql.rowsiFromStatement(0x513000, 0xc000016168, 0x512f00, 0xc000010290, 0xc00005c240, 0x0, 0x0, 0x0, 0x0, 0x0, ...) /work/rakhil/go/src/database/sql/sql.go:2511 +0x159 database/sql.(*Stmt).QueryContext(0xc0000a8000, 0x513000, 0xc000016168, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0) /work/rakhil/go/src/database/sql/sql.go:2463 +0x203 database/sql.(*Stmt).QueryRowContext(0xc0000a8000, 0x513000, 0xc000016168, 0x0, 0x0, 0x0, 0xc000016248) /work/rakhil/go/src/database/sql/sql.go:2521 +0x6d database/sql.(*Stmt).QueryRow(0xc0000a8000, 0x0, 0x0, 0x0, 0x0) /work/rakhil/go/src/database/sql/sql.go:2540 +0x61 main.main.func1(0xc0000a8000, 0xc0000a8090, 0xc00001c2a0) /home/rakhil/go/src/github.com/bradfitz/go-sql-test/src/akh.go:46 +0x87 created by main.main /home/rakhil/go/src/github.com/bradfitz/go-sql-test/src/akh.go:43 +0x472
THE DRIVER WORKS FINE FOR WINDOWS BUT IT PRODUCES THE ABOVE ERROR FOR LINUX.
Thanks
-
Patch for SQLite
Hello, I don't know if you can reproduce the following problem. On my laptop, the tests fail: --- FAIL: TestPreparedStmt_SQLite (7.96 seconds) sql_test.go:367: Insert: database is locked sql_test.go:367: Insert: database is locked sql_test.go:367: Insert: database is locked sql_test.go:367: Insert: database is locked
I can make it passed by increasing the busy timeout in mattn driver:
diff --git a/sqlite3.go b/sqlite3.go index 0a21d23..7532039 100644 --- a/sqlite3.go +++ b/sqlite3.go @@ -120,7 +120,7 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) { return nil, errors.New("sqlite succeeded without returning a database") } - rv = C.sqlite3_busy_timeout(db, 5000) + rv = C.sqlite3_busy_timeout(db, 10000) if rv != C.SQLITE_OK { return nil, errors.New(C.GoString(C.sqlite3_errmsg(db))) }
Regards.
-
Picking wrong driver and creating an gcc error
Hi , I have added my driver in your src path and have written functions to my driver but why it is not picking up my driver insted it is picking ziutek driver.
runtime/cgo exec: "gcc": executable file not found in %PATH% github.com/ziutek/mymysql/native ..\github.com\ziutek\mymysql\native\codecs.go:286:3: cannot fallthrough final case in switch FAIL sqltest [build failed]
Thanks
-
add go-mssqldb tests
This PR adds support for github.com/denisenkom/go-mssqldb, a pure Go driver for SQL Server.
I've updated the README with instructions for creating the database and setting the environment variables that the tests expect to be present.
The tests expect port 1433, the default port for the default SQL Server instance, to be listening on localhost; if the port is not open, then the tests will not run. The tests run against a database named
gosqltest
. The username and password are specified using environment variables namedGOSQLTEST_MSSQL_USER
andGOSQLTEST_MSSQL_PASS
, respectively.GOSQLTEST_MSSQL_USER
must be set, butGOSQLTEST_MSSQL_PASS
does not; the tests will use a default password ofgosqltest
if the environment variable is not set.I ran these tests on an OS X machine that had port 1433 forwarded to a Vagrant machine running SQL Server.
-
should go-sql-test also verify time.Time struct's location?
should go-sql-test also verify time.Time struct's location? As I've found that lib/pq has inconsistent behavior on retrieving datetime and time type column (https://github.com/lib/pq/issues/251)
Related tags
Go package for sharding databases ( Supports every ORM or raw SQL )
Octillery Octillery is a Go package for sharding databases. It can use with every OR Mapping library ( xorm , gorp , gorm , dbr ...) implementing data
Cross-platform client for PostgreSQL databases
pgweb Web-based PostgreSQL database browser written in Go. Overview Pgweb is a web-based database browser for PostgreSQL, written in Go and works on O
Universal command-line interface for SQL databases
usql A universal command-line interface for PostgreSQL, MySQL, Oracle Database, SQLite3, Microsoft SQL Server, and many other databases including NoSQ
OctoSQL is a query tool that allows you to join, analyse and transform data from multiple databases and file formats using SQL.
OctoSQL OctoSQL is a query tool that allows you to join, analyse and transform data from multiple databases, streaming sources and file formats using
Redis-shake is a tool for synchronizing data between two redis databases. Redis-shake是一个用于在两个redis之间同步数据的工具,满足用户非常灵活的同步、迁移需求。
RedisShake is mainly used to synchronize data from one redis to another. Thanks to the Douyu's WSD team for the support. 中文文档 English tutorial 中文使用文档
SQL API is designed to be able to run queries on databases without any configuration by simple HTTP call.
SQL API SQL API is designed to be able to run queries on databases without any configuration by simple HTTP call. The request contains the DB credenti
Go sqlite3 http vfs: query sqlite databases over http with range headers
sqlite3vfshttp: a Go sqlite VFS for querying databases over http(s) sqlite3vfshttp is a sqlite3 VFS for querying remote databases over http(s). This a
The open-source collaborative IDE for your databases.
The open-source collaborative IDE for your databases in your browser. About Slashbase is an open-source collaborative IDE for your databases in your b
Cross-platform client for PostgreSQL databases
pgweb Web-based PostgreSQL database browser written in Go. Overview Pgweb is a web-based database browser for PostgreSQL, written in Go and works on O
Use SQL to instantly query instances, networks, databases, and more from Scaleway. Open source CLI. No DB required.
Scaleway Plugin for Steampipe Use SQL to query infrastructure servers, networks, databases and more from your Scaleway project. Get started → Document
Manage SQL databases, users and grant using kubernetes manifests
SqlOperator Operate sql databases, users and grants. This is a WIP project and should not at all be used in production at this time. Feel free to vali
Manage Schema for KubeDB managed Databases
schema-manager Manage Schema for KubeDB managed Databases Installation To install KubeDB, please follow the guide here. Using KubeDB Want to learn how
A go Library for scan database/sql rows to struct、slice、other types. And it support multiple databases connection management
ploto A go Library for scan database/sql rows to struct、slice、other types. And it support multiple databases connection management It's not an ORM. wo
SQLite extension for accessing other SQL databases
dblite SQLite extension for accessing other SQL databases, in SQLite. Similar to how Postgres Foreign Data Wrappers enable access to other databases i
Client to import measurements to timestream databases.
Timestream DB Client Client to import measurements to timestream databases. Supported Databases/Services AWS Timestream AWS Timestream Run NewTimestre
Use SQL to query databases, logs and more from PlanetScale
Use SQL to instantly query PlanetScale databases, branches and more. Open source CLI. No DB required.
This is the code example how to use SQL to query data from any relational databases in Go programming language.
Go with SQL example This is the code example how to use SQL to query data from any relational databases in Go programming language. To start, please m
A simple auditor of SQL databases.
DBAuditor SQL数据库审计系统,目前支持SQL注入攻击审计 环境配置 sudo apt install golang 运行方式 将待审计语句填入test.txt中,然后运行主程序: 直接运行: go run main.go 编译运行: go build main.go ./main 主要目
Prep finds all SQL statements in a Go package and instruments db connection with prepared statements
Prep Prep finds all SQL statements in a Go package and instruments db connection with prepared statements. It allows you to benefit from the prepared