db_bridge/main.cpp
author Markus Bröker <mbroeker@largo.dyndns.tv>
Sat, 13 Dec 2008 17:58:06 +0100
changeset 14 862d63715611
parent 12 9f0ce4eaa1ce
child 15 5a0ca1f9a2f1
permissions -rw-r--r--
the long vector needs a typedef committer: Markus Bröker <mbroeker@largo.homelinux.org>

/**
 * db_bridge/main.cpp
 * Copyright (C) 2008 Markus Broeker
 */

#ifdef WITH_POSTGRESQL
#include <postgresql_db.h>
#else
#include <mysql_db.h>
#endif

int main (int argc, char **argv)
{
    Abstract_DB *db;

    Abstract_DB::DB_ROW vec;
    Abstract_DB::DB_RESULT result;
    unsigned int i, j;

#ifdef WITH_POSTGRESQL
    db = new PostgreSQL_DB ("", "largo", "", "clubstatistik");
#else
    db = new MySQL_DB ("localhost", "dbuser", "dbpasswd", "datenbank");
#endif

    if (db->connect () == false) {
        std::cerr << "Kann mich nicht zur Datenbank verbinden. Passwoerter falsch?" << std::endl;
        return EXIT_FAILURE;
    }

    result = db->query ("select * from euroleague");

    for (i = 0; i < result.size (); i++) {
        vec = result[i];
        for (j = 0; j < vec.size (); j++) {
            std::cout << vec[j] << " ";
        }
        std::cout << std::endl;
    }

    delete db;

    return EXIT_SUCCESS;
}