intro.bbdoc 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. ![PostgreSQL](postgresql_logo.png)
  2. The PostgreSQL database driver allows you to connect to PostgreSQL databases through the standard API provided by the Database Framework module.
  3. ## Requirements
  4. You will need the PostgreSQL (libpq) client libraries installed. Instructions to do this varies depending on your platform.
  5. ### Platform Specifics
  6. #### Windows
  7. Windows installers are available from the [PostgreSQL website](https://www.postgresql.org/download/windows/).
  8. The libpq client library is not required to build, but is required to run the application.
  9. You will likely need to add the PostgreSQL bin directory to your PATH environment variable.
  10. #### Linux
  11. For compiliation on Linux, you will need to install the PostgreSQL "dev" packages. On Ubuntu and Debian, this can be done with the following command:
  12. ```
  13. sudo apt install libpq-dev
  14. ```
  15. Once installed, the build should be able to determine the correct location of the PostgreSQL libraries.
  16. #### MacOS
  17. The PostgreSQL database driver assumes you will be using the [Homebrew](http://brew.sh/) package manager to install the PostgreSQL client libraries.
  18. This can be done using the following command :
  19. ```
  20. brew install libpq
  21. ```
  22. Depending on which version of libpq gets installed, you may need to modify the module source code to point to the correct location of the PostgreSQL libraries.
  23. ## Accessing a PostgreSQL Database
  24. To enable a PostgreSQL connection, you simply pass a *dbtype* of **POSTGRESQL** to the #LoadDatabase function.
  25. The *dbname* parameter refers to the name of the database you wish to connect to.
  26. The *host* and *port* parameters are optional if you are connecting to a local PostgreSQL server.
  27. *user* and *password* should be filled in as required.
  28. ## Prepared Statement Placeholders
  29. PostgreSQL placeholders are defined by the form $n. Where n is a number starting at 1. (for example, $1, would be the first parameter).
  30. Remember that the Database Framework bindings start at 0, rather than 1, so in the code, binding to 0 would actual bind to the placeholder $1.
  31. ## SQL with PostgreSQL
  32. For a complete guide to the PostgreSQL syntax, you can browse the excellent online documentation [here](http://www.postgresql.org/).