Search by Tags

How to use PostgreSQL in C

 
Subscribe for this article updates

Postgres is a relational database management system. Postgres is a popular choice for relational databases. It is one of the most widely deployed database engine, as it is used today by several prominent organizations and products.

Use Cases

  • Inventory manager
  • Billing station
  • Automated Parking System
  • Attendance system
  • and many more..

Notes:

  • The above Postgres demo only demonstrates the use of a Postgres client running on the module.
  • Running PostgreSQL server on the module is not supported.
  • The PostgreSQL server has to be run remotely on a desktop or server machine.
  • PostgreSQL can be downloaded from here.
  • For managing the PostgreSQL database on the desktop or server, the pgAdminIII tool can be downloaded from here.
  • Documentation for pgAdminIII and PostgreSQL.

Download

  • Download the postgres_demo source code from here.

Steps to run Postgres Demo

  • Setup WinCE development environment using this link.
  • Modify the CONNECTION_STRING constant in the demo code as per your set up.
  • Build postgres_demo.sln in Visual Studio 2008 and then deploy on Colibri device.
  • Navigate to Program Files on Colibri device, project folder and run postgres_demo.exe.

Following window will open showing different choices for PostgresDemo.


Enter 1 to connect to the database.


Enter 2 and the SELECT query to display the table data in database.

Similarly

  • To insert, enter 3 & then the INSERT query to be executed. For example: INSERT INTO ceshcema.cetable VALUES ('Chris', 21, 8, 1967).
  • To modify, enter 4 & then the UPDATE query to be executed. For example: UPDATE ceschema.cetable SET "Date" = 4 WHERE "Year" = 1967.
  • To delete, enter 5 & then the DELETE query to be executed. For example: DELETE FROM ceschema.cetable WHERE "Year"=1967.
  • To modify the table structure, enter 6 and then the ALTER query to be executed. For example: ALTER TABLE ceschema.cetable ADD COLUMN Address varchar(50).
  • To close the connection and exit, enter 7.