4 // #include <dbi/dbi.h>
11 type DBIConnection struct {
16 func DBICreate()(connection *DBIConnection)
18 var dbCon *DBIConnection;
20 dbCon = new(DBIConnection);
26 //func (thisDBConn *DBIConnection)DBIConnect(dbtype string, host string, username string, password string, database string)
27 // for some reason, the above doesnt work how i'd expect..
28 func DBIConnect(thisDBConn *DBIConnection, dbtype string, host string, username string, password string, database string)
30 C.dbi_initialize(nil);
32 thisDBConn.dbconn = C.dbi_conn_new(C.CString(dbtype));
34 C.dbi_conn_set_option((unsafe.Pointer)(thisDBConn.dbconn), C.CString("host"), C.CString(host));
35 C.dbi_conn_set_option((unsafe.Pointer)(thisDBConn.dbconn), C.CString("username"), C.CString(username));
36 C.dbi_conn_set_option((unsafe.Pointer)(thisDBConn.dbconn), C.CString("password"), C.CString(password));
37 C.dbi_conn_set_option((unsafe.Pointer)(thisDBConn.dbconn), C.CString("dbname"), C.CString(database));
38 C.dbi_conn_connect((unsafe.Pointer)(thisDBConn.dbconn));
40 thisDBConn.dbinit = true;
43 func ExecSQL(thisDBConn *DBIConnection, SQL string)
45 C.dbi_conn_query((unsafe.Pointer)(thisDBConn.dbconn), C.CString(SQL));
48 func DBIDisconnect(thisDBConn *DBIConnection)
50 C.dbi_conn_close((unsafe.Pointer)(thisDBConn.dbconn));