package dbibridge // #include // #include import "C" import ( "unsafe"; ) type DBIConnection struct { dbconn C.dbi_conn; dbinit bool; } func DBICreate()(connection *DBIConnection) { var dbCon *DBIConnection; dbCon = new(DBIConnection); dbCon.dbinit = false; return dbCon; } //func (thisDBConn *DBIConnection)DBIConnect(dbtype string, host string, username string, password string, database string) // for some reason, the above doesnt work how i'd expect.. func DBIConnect(thisDBConn *DBIConnection, dbtype string, host string, username string, password string, database string) { C.dbi_initialize(nil); thisDBConn.dbconn = C.dbi_conn_new(C.CString(dbtype)); C.dbi_conn_set_option((unsafe.Pointer)(thisDBConn.dbconn), C.CString("host"), C.CString(host)); C.dbi_conn_set_option((unsafe.Pointer)(thisDBConn.dbconn), C.CString("username"), C.CString(username)); C.dbi_conn_set_option((unsafe.Pointer)(thisDBConn.dbconn), C.CString("password"), C.CString(password)); C.dbi_conn_set_option((unsafe.Pointer)(thisDBConn.dbconn), C.CString("dbname"), C.CString(database)); C.dbi_conn_connect((unsafe.Pointer)(thisDBConn.dbconn)); thisDBConn.dbinit = true; } func ExecSQL(thisDBConn *DBIConnection, SQL string) { C.dbi_conn_query((unsafe.Pointer)(thisDBConn.dbconn), C.CString(SQL)); } func DBIDisconnect(thisDBConn *DBIConnection) { C.dbi_conn_close((unsafe.Pointer)(thisDBConn.dbconn)); }