Created
July 11, 2015 01:41
-
-
Save TheBuzzSaw/c756b0919760372095e5 to your computer and use it in GitHub Desktop.
The postgres API is gross...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <libpq-fe.h> | |
| #include <iostream> | |
| using namespace std; | |
| int main(int argc, char** argv) | |
| { | |
| PGconn* connection = PQconnectdb( | |
| "host=localhost port=5432 dbname=swccg user=postgres"); | |
| if (PQstatus(connection) == CONNECTION_OK) | |
| { | |
| PGresult* result = PQexec(connection, "SELECT * FROM legacy_card_info"); | |
| cout << PQntuples(result) << " rows" << endl; | |
| cout << PQnfields(result) << " columns" << endl; | |
| PQclear(result); | |
| } | |
| else | |
| { | |
| cerr << PQerrorMessage(connection) << '\n'; | |
| } | |
| PQfinish(connection); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment