Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <libpq-fe.h>
  3.  
  4. int main()
  5. {
  6. PGresult *result;
  7. PGconn *conn;
  8. conn = PQconnectdb("host=localhost port=5432 dbname=nazwa user=login password=haslo"); if(PQstatus(conn) == CONNECTION_OK)
  9. {
  10. result = PQexec(conn, "SELECT * FROM number");
  11. if(PQresultStatus(result)==PGRES_TUPLES_OK)
  12. {
  13. PQprintOpt pqp;
  14. pqp.header = 1;
  15. pqp.align = 1;
  16. pqp.html3 = 1;
  17. pqp.expanded = 0;
  18. pqp.pager = 0;
  19. pqp.fieldSep = "";
  20. pqp.tableOpt = "align=center";
  21. pqp.caption = "Bingham Customer List";
  22. pqp.fieldName = NULL;
  23. printf("<HTML><HEAD></HEAD><BODY>\n");
  24. PQprint(stdout, result, &pqp);
  25. printf("</BODY></HTML>\n");
  26. }
  27. }
  28. PQfinish(conn);
  29. return EXIT_SUCCESS;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement