db creation things
authorPaul J R <me@pjr.cc>
Sun, 15 Nov 2009 14:07:32 +0000 (01:07 +1100)
committerPaul J R <me@pjr.cc>
Sun, 15 Nov 2009 14:07:32 +0000 (01:07 +1100)
src/dbconnector.go

index 5a6f64b..e09ebe9 100644 (file)
@@ -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);
 }