func (ae *SQLAuctionEngine) DestroyHandler() (err error) {
	if ae.DBHandler == nil {
		err = fmt.Errorf("Error, cannot destroy nil handler, please create new engine")
		return
	}
	if err = ae.DBHandler.Close(); err != nil {
		err = fmt.Errorf("Error closing engine handler for DestroyHandler: %s", err)
		return
	}
	ae.DBHandler = nil
	return
}
DestroyHandler closes the DB handler that we created, and makes it nil
package cxdbsql
import (
	"database/sql"
	"encoding/hex"
	"fmt"
	"net"
	_ "github.com/go-sql-driver/mysql"
	"github.com/mit-dci/opencx/logging"
	"github.com/mit-dci/opencx/match"
	"golang.org/x/crypto/sha3"
)
type SQLAuctionEngine struct {
	DBHandler *sql.DB
	dbUsername string
	dbPassword string
	dbAddr net.Addr
	auctionOrderSchema string
	pair *match.Pair
}
const (
	auctionEngineSchema = "pubkey VARBINARY(66), side TEXT, price DOUBLE(30, 2) UNSIGNED, amountHave BIGINT(64), amountWant BIGINT(64), auctionID VARBINARY(64), nonce VARBINARY(4), sig BLOB, hashedOrder VARBINARY(64), PRIMARY KEY (hashedOrder)"
)
func CreateAuctionEngineWithConf(pair *match.Pair, conf *dbsqlConfig) (engine match.AuctionEngine, err error) {
	var ae *SQLAuctionEngine
	if ae, err = CreateAucEngineStructWithConf(pair, conf); err != nil {
		err = fmt.Errorf("Error creating auction engine struct w/ conf for CreateAuctionEngineWithConf: %s", err)
		return
	}
	engine = ae
	return
}
func CreateAucEngineStructWithConf(pair *match.Pair, conf *dbsqlConfig) (engine *SQLAuctionEngine, err error) {
	dbConfigSetup(conf)
	var addr net.Addr
	if addr, err = net.ResolveTCPAddr("tcp", net.JoinHostPort(conf.DBHost, fmt.Sprintf("%d", conf.DBPort))); err != nil {
		err = fmt.Errorf("Couldn't resolve db address for createAuctionEngine: %s", err)
		return
	}
	ae := &SQLAuctionEngine{
		dbUsername:         conf.DBUsername,
		dbPassword:         conf.DBPassword,
		auctionOrderSchema: conf.AuctionSchemaName,
		dbAddr:             addr,
		pair:               pair,
	}
	if err = ae.setupAuctionOrderbookTables(); err != nil {
		err = fmt.Errorf("Error setting up auction orderbook tables while creating engine: %s", err)
		return
	}
	openString := fmt.Sprintf("%s:%s@%s(%s)/", ae.dbUsername, ae.dbPassword, ae.dbAddr.Network(), ae.dbAddr.String())
	if ae.DBHandler, err = sql.Open("mysql", openString); err != nil {
		err = fmt.Errorf("Error opening database for createAuctionEngine: %s", err)
		return
	}
	if err = ae.DBHandler.Ping(); err != nil {
		err = fmt.Errorf("Could not ping the database, is it running: %s", err)
		return
	}
	engine = ae
	return
}
func CreateAuctionEngine(pair *match.Pair) (engine match.AuctionEngine, err error) {
	conf := new(dbsqlConfig)
	*conf = *defaultConf
	if engine, err = CreateAuctionEngineWithConf(pair, conf); err != nil {
		return
	}
	return
}
func (ae *SQLAuctionEngine) setupAuctionOrderbookTables() (err error) {
	openString := fmt.Sprintf("%s:%s@%s(%s)/", ae.dbUsername, ae.dbPassword, ae.dbAddr.Network(), ae.dbAddr.String())
	var rootHandler *sql.DB
	if rootHandler, err = sql.Open("mysql", openString); err != nil {
		err = fmt.Errorf("Error opening database for setup auction tables: %s", err)
		return
	}
	defer rootHandler.Close()
	if err = rootHandler.Ping(); err != nil {
		err = fmt.Errorf("Could not ping the database, is it running: %s", err)
		return
	}
	var tx *sql.Tx
	if tx, err = rootHandler.Begin(); err != nil {
		err = fmt.Errorf("Error when beginning transaction for setup auction tables: %s", err)
		return
	}
	defer func() {
		if err != nil {
			tx.Rollback()
			err = fmt.Errorf("Error while matching setup auction tables: \n%s", err)
			return
		}
		err = tx.Commit()
	}()
	if _, err = tx.Exec("CREATE SCHEMA IF NOT EXISTS " + ae.auctionOrderSchema + ";"); err != nil {
		err = fmt.Errorf("Error creating schema for setup auction order tables: %s", err)
		return
	}
	if _, err = tx.Exec("USE " + ae.auctionOrderSchema + ";"); err != nil {
		err = fmt.Errorf("Could not use %s schema: %s", ae.auctionOrderSchema, err)
		return
	}
	createTableQuery := fmt.Sprintf("CREATE TABLE IF NOT EXISTS %s (%s);", ae.pair.String(), auctionEngineSchema)
	if _, err = tx.Exec(createTableQuery); err != nil {
		err = fmt.Errorf("Error creating auction orderbook table: %s", err)
		return
	}
	return
}