1 // um yes... its a db connector
10 type DBConnector struct {
15 func CreateRandomText(len int) (str string)
17 buf := make([]byte, len+2);
19 rand.Seed(time.Nanoseconds());
21 for i:=0; i<len; i++ {
22 switch(rand.Int()%3) {
24 buf[i] = uint8(rand.Int()%26+65);
26 buf[i] = uint8(rand.Int()%26+97);
28 buf[i] = uint8(rand.Int()%10+48);
37 func DBSetup(dbtype string, host string, username string, password string, database string, datamult int, comout chan int)
40 // the job of this function is to bring up the connection and create tables based on dbtype
41 var Dbconn *dbibridge.DBIConnection;
43 Dbconn = dbibridge.DBICreate();
45 dbibridge.DBIConnect(Dbconn, "mysql", host, username, password, database);
47 if dbtype == "mysql" {
48 dbibridge.ExecSQL(Dbconn,"create table WAREHOUSE ( \
49 W_ID integer NOT NULL, \
50 W_NAME CHARACTER(10), \
51 W_STREET_1 CHARACTER(20), \
52 W_STREET_2 CHARACTER(20), \
53 W_CITY CHARACTER(20), \
54 W_STATE CHARACTER(2), \
60 dbibridge.ExecSQL(Dbconn,"create table DISTRICT ( \
61 D_ID integer NOT NULL, \
62 D_W_ID integer NOT NULL, \
63 D_NAME CHARACTER(10), \
64 D_STREET_1 CHARACTER(20), \
65 D_STREET_2 CHARACTER(20), \
66 D_CITY CHARACTER(20), \
67 D_STATE CHARACTER(2), \
71 D_NEXT_O_ID integer, \
72 PRIMARY KEY(D_W_ID, D_ID))");
74 dbibridge.ExecSQL(Dbconn,"create table ITEM ( \
75 I_ID integer NOT NULL, \
77 I_NAME CHARACTER(24), \
79 I_DATA CHARACTER(50), \
83 for i := 1; i < 100; i += 10 {
84 time.Sleep(1000000000);
89 // now we need to actually create data in the tables...
92 dbibridge.DBIDisconnect(Dbconn);