X-Git-Url: http://git.pjr.cc/?a=blobdiff_plain;f=src%2Fdbconnector.go;h=e09ebe9af23e93a73a078bd354239ae98f13109b;hb=bb4d7a9f770f69fe0317d6f6e525df6d6611fbbd;hp=f8b91317ad0c1a2c6ded722621ad5946b025cdbd;hpb=70e916f77d2ccc9b296e53981ccca0c11798e0d5;p=goDBhammer.git diff --git a/src/dbconnector.go b/src/dbconnector.go index f8b9131..e09ebe9 100644 --- a/src/dbconnector.go +++ b/src/dbconnector.go @@ -1 +1,58 @@ -// um yes... its a db connector \ No newline at end of file +// um yes... its a db connector +package dbconnector + +type DBConnector struct { + // err, yes +} + +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; + + Dbconn = dbibridge.DBICreate(); + + 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); +} + + +