#include #include #include #include #include #include int main(int argc, char * argv[]) { TDEInstance instance("newapi"); KexiDB::DriverManager manager; TQStringList names = manager.driverNames(); kdDebug() << "DRIVERS: " << endl; for (TQStringList::ConstIterator it = names.constBegin(); it != names.constEnd() ; ++it) kdDebug() << *it << endl; if (manager.error()) { kdDebug() << manager.errorMsg() << endl; return 1; } //get driver KexiDB::Driver *driver = manager.driver("mySQL"); if (manager.error()) { kdDebug() << manager.errorMsg() << endl; return 1; } //connection data that can be later reused KexiDB::ConnectionData conn_data; conn_data.userName="root"; if (argc>1) conn_data.password=argv[1]; else conn_data.password="mysql"; conn_data.hostName="localhost"; KexiDB::Connection *conn = driver->createConnection(conn_data); if (driver->error()) { kdDebug() << driver->errorMsg() << endl; return 1; } if (!conn->connect()) { kdDebug() << conn->errorMsg() << endl; return 1; } if (!conn->useDatabase( "test" )) { kdDebug() <<"use db:"<< conn->errorMsg() << endl; return 1; } kdDebug()<<"Creating first cursor"<executeQuery("select * from Applications"); if (!c) kdDebug()<errorMsg()<executeQuery("select * from Applications"); if (!c2) kdDebug()<errorMsg()<databaseNames(); if (l.isEmpty()) kdDebug()<errorMsg()<moveNext()) { kdDebug()<<"Cursor: Value(0)"<value(0).asString()<value(1).asString()<errorMsg()<moveNext()) { kdDebug()<<"Cursor2: Value(0)"<value(0).asString()<value(1).asString()<movePrev()) { kdDebug()<<"Cursor: Value(0)"<value(0).asString()<value(1).asString()<moveNext(); kdDebug()<<"Cursor: Value(0)"<value(0).asString()<value(1).asString()<moveNext(); kdDebug()<<"Cursor: Value(0)"<value(0).asString()<value(1).asString()<movePrev(); kdDebug()<<"Cursor: Value(0)"<value(0).asString()<value(1).asString()<movePrev(); kdDebug()<<"Cursor: Value(0)"<value(0).asString()<value(1).asString()<tableSchema( "persons" ); if (t) t->debug(); t = conn->tableSchema( "cars" ); if (t) t->debug(); // conn->tableNames(); if (!conn->disconnect()) { kdDebug() << conn->errorMsg() << endl; return 1; } debug("before del"); delete conn; debug("after del"); #endif return 0; }