From: Paul J R Date: Sun, 15 Nov 2009 14:07:32 +0000 (+1100) Subject: db creation things X-Git-Url: http://git.pjr.cc/?a=commitdiff_plain;h=bb4d7a9f770f69fe0317d6f6e525df6d6611fbbd;p=goDBhammer.git db creation things --- diff --git a/src/dbconnector.go b/src/dbconnector.go index 5a6f64b..e09ebe9 100644 --- a/src/dbconnector.go +++ b/src/dbconnector.go @@ -5,18 +5,53 @@ type DBConnector struct { // err, yes } -func DBSetup(dbtype string, host string, username string, password string, database string, createtables bool) +func DBSetup(dbtype string, host string, username string, password string, database string, datamult int, comout chan int) { // the job of this function is to bring up the connection and create tables based on dbtype - //var Dbconn *dbibridge.DBIConnection; + var Dbconn *dbibridge.DBIConnection; - //Dbconn = dbibridge.DBICreate(); + Dbconn = dbibridge.DBICreate(); - //dbibridge.DBIConnect(Dbconn, "mysql", "localhost", "root", "password", "zm"); - //dbibridge.ExecSQL(Dbconn, "create table asdf (asdf int)"); - //dbibridge.DBIDisconnect(Dbconn); + dbibridge.DBIConnect(Dbconn, "mysql", host, username, password, database); + + if dbtype == "mysql" { + dbibridge.ExecSQL("create table WAREHOUSE ( + W_ID integer NOT NULL, + W_NAME CHARACTER(10), + W_STREET_1 CHARACTER(20), + W_STREET_2 CHARACTER(20), + W_CITY CHARACTER(20), + W_STATE CHARACTER(2), + W_ZIP CHARACTER(9), + W_TAX integer, + W_YTD integer, + PRIMARY KEY(W_ID))"); + + dbibridge.ExecSQL("create table DISTRICT ( + D_ID integer NOT NULL, + D_W_ID integer NOT NULL, + D_NAME CHARACTER(10), + D_STREET_1 CHARACTER(20), + D_STREET_2 CHARACTER(20), + D_CITY CHARACTER(20), + D_STATE CHARACTER(2), + D_ZIP CHARACTER(9), + D_TAX integer, + D_YTD integer, + D_NEXT_O_ID integer, + PRIMARY KEY(D_W_ID, D_ID))"); + + dbibridge.ExecSQL("create table ITEM ( + I_ID integer NOT NULL, + I_IM_ID integer, + I_NAME CHARACTER(24), + I_PRICE integer, + I_DATA CHARACTER(50), + PRIMARY KEY(I_ID))"); + } + dbibridge.DBIDisconnect(Dbconn); }