From bb4d7a9f770f69fe0317d6f6e525df6d6611fbbd Mon Sep 17 00:00:00 2001 From: Paul J R Date: Mon, 16 Nov 2009 01:07:32 +1100 Subject: [PATCH] db creation things --- src/dbconnector.go | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 41 insertions(+), 6 deletions(-) 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); } -- 1.7.0.4