author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Sat, 13 Dec 2008 17:58:06 +0100 | |
changeset 13 | 2640a7fd96ca |
parent 12 | 9f0ce4eaa1ce |
child 14 | 862d63715611 |
permissions | -rw-r--r-- |
12
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
1 |
/** |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
2 |
* db_bridge/main.cpp |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
3 |
* Copyright (C) 2008 Markus Broeker |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
4 |
*/ |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
5 |
|
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
6 |
#ifdef WITH_POSTGRESQL |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
7 |
#include <postgresql_db.h> |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
8 |
#else |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
9 |
#include <mysql_db.h> |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
10 |
#endif |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
11 |
|
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
12 |
int main (int argc, char **argv) |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
13 |
{ |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
14 |
Abstract_DB *db; |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
15 |
|
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
16 |
std::vector <std::string> vec; |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
17 |
std::vector <std::vector <std::string> >result; |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
18 |
unsigned int i, j; |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
19 |
|
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
20 |
#ifdef WITH_POSTGRESQL |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
21 |
db = new PostgreSQL_DB ("", "largo", "", "clubstatistik"); |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
22 |
#else |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
23 |
db = new MySQL_DB ("localhost", "dbuser", "dbpasswd", "datenbank"); |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
24 |
#endif |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
25 |
|
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
26 |
if (db->connect () == false) { |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
27 |
std::cerr << "Kann mich nicht zur Datenbank verbinden. Passwoerter falsch?" << std::endl; |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
28 |
return EXIT_FAILURE; |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
29 |
} |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
30 |
|
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
31 |
result = db->query ("select * from euroleague"); |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
32 |
|
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
33 |
for (i = 0; i < result.size (); i++) { |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
34 |
vec = result[i]; |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
35 |
for (j = 0; j < vec.size (); j++) { |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
36 |
std::cout << vec[j] << " "; |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
37 |
} |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
38 |
std::cout << std::endl; |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
39 |
} |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
40 |
|
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
41 |
delete db; |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
42 |
|
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
43 |
return EXIT_SUCCESS; |
9f0ce4eaa1ce
I added a small db_bridge to the repository
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
44 |
} |