1 2 #include <migration/migratemanager.h> 3 #include <migration/keximigrate.h> 4 5 #include <KAboutData> 6 7 #include <QApplication> 8 #include <QDebug> 9 main(int argc,char * argv[])10int main(int argc, char *argv[]) 11 { 12 KAboutData aboutData("keximigratetest", 0, kxi18n("Kexi Migrate Test"), "2.0"); 13 KCmdLineArgs::init(argc, argv, &aboutData); 14 KApplication app; 15 16 KexiMigration::MigrateManager mm; 17 18 qDebug() << mm.driverIds(); 19 20 //Text File Test 21 KexiMigration::KexiMigrate *m = mm.driver("Text"); 22 23 KDbConnectionData cd; 24 25 cd.setFileName("/home/piggz/tabdata.txt"); 26 27 KexiMigration::Data d; 28 d.source = &cd; 29 30 m->setData(&d); 31 32 m->connectSource(); 33 34 KDbTableSchema ts; 35 36 if (!m->readTableSchema("tabdata.txt", ts)) 37 { 38 qDebug() << "Unable to read schema"; 39 return 0; 40 } 41 42 if (!m->readFromTable("tabdata.txt")) 43 { 44 qDebug() << "Unable to read from table"; 45 return 0; 46 } 47 48 while(m->moveNext()) 49 { 50 qDebug() << m->value(0) << m->value(1) << m->value(2); 51 } 52 53 m->movePrevious(); 54 qDebug() << m->value(0) << m->value(1) << m->value(2); 55 56 m->moveNext(); 57 qDebug() << m->value(0) << m->value(1) << m->value(2); 58 59 m->movePrevious(); 60 qDebug() << m->value(0) << m->value(1) << m->value(2); 61 62 m->movePrevious(); 63 qDebug() << m->value(0) << m->value(1) << m->value(2); 64 65 m->movePrevious(); 66 qDebug() << m->value(0) << m->value(1) << m->value(2); 67 68 m->moveNext(); 69 qDebug() << m->value(0) << m->value(1) << m->value(2); 70 71 72 //KSpread file test 73 74 KexiMigration::KexiMigrate *k = mm.driver("KSpread"); 75 cd.setFileName("/home/piggz/Documents/database.fods"); 76 k->setData(&d); 77 78 k->connectSource(); 79 QStringList tn; 80 k->tableNames(tn); 81 82 qDebug() << tn; 83 KDbTableSchema ts2; 84 if (!k->readTableSchema("Names", ts2)) 85 { 86 qDebug() << "Unable to read schema"; 87 return 0; 88 } 89 90 k->readFromTable("Names"); 91 92 while(k->moveNext()) 93 { 94 qDebug() << k->value(0) << k->value(1) << k->value(2); 95 } 96 } 97