Skip to content

PuppyKhan/dbhammer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 

Repository files navigation

dbhammer

A simple MySQL Go driver test utility.

By Luigi Kapaj <puppy at viahistoria.com>

This requires a mysql server setup to run test scripts against, with location and credential set as environment variables, and (if used) a preset stored procedure.

Test server environment variables

Location and credentials for the MySQL server are accessed through the following environment variables. Adjust as necessary for your local system.

export MYSQL_TEST_USER=root
export MYSQL_TEST_PASS=mysql
export MYSQL_TEST_DBNAME=gotest
export MYSQL_TEST_PROT=tcp
export MYSQL_TEST_ADDR=localhost
export MYSQL_TEST_PORT=3306

Stored Procedure test

The test db requires these Stored Procedures to be manual setup in order to use the -sp flag.

DELIMITER //
CREATE PROCEDURE hello_world() BEGIN SELECT 'Hello, World!'; END//
DELIMITER ;
DELIMITER //
CREATE PROCEDURE good_bye() BEGIN DECLARE something INT DEFAULT 0; SET something=2; END//
DELIMITER ;

Imports

This utility makes use of all the following imports to build. The specific MySQL driver gets chosen at runtime.

go get -u github.com/ziutek/mymysql/mysql
go get -u github.com/ziutek/mymysql/native
go get -u github.com/ziutek/mymysql/godrv
go get -u github.com/go-sql-driver/mysql

No longer uses forked drivers:

go get -u github.com/PuppyKhan/mymysql/mysql
go get -u github.com/PuppyKhan/mymysql/native
go get -u github.com/PuppyKhan/mymysql/godrv
go get -u github.com/PuppyKhan/mysql

Parameters and Defaults

$ dbhammer -help
Usage of dbhammer:
  -conns=256: Set # open/idle connections
  -db="mysql": Select driver: mymysql or mysql
  -error=false: Test an error in SQL statement
  -sp=false: Test running stored procedure
  -tries=100: Set # rows to try

Sample running command

dbhammer -db=mysql -conns=1 -sp

This uses the "github.com/PuppyKhan/mysql" driver, only allows 1 open or idle connection, and tests stored procedures.

Note that setting "-conns=1" is useful for surfacing resource leaks in the buffer.

About

A simple mysql driver test util

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages