db creation things
[goDBhammer.git] / src / dbconnector.go
index f8b9131..e09ebe9 100644 (file)
@@ -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);
+}
+
+
+