Welcome to PostgreSQL with C++: City Explorer! ๐ This project showcases a simple yet powerful example of how to connect a C++ application to a PostgreSQL database using the libpqxx
library. With this project, you can explore the 10 largest cities in the USA right from your terminal! ๐
- Easy Setup ๐ ๏ธ: Quickly set up and get started with minimal configuration.
- Simple Interface ๐ป: Interact with the database through a clean and intuitive terminal interface.
- Robust Design ๐๏ธ: Organized code structure with a dedicated PostgreSQL class for easy database management.
- Educational ๐: Perfect for learning how to integrate C++ with PostgreSQL using
libpqxx
.
- Learn by Doing ๐จโ๐ป: Hands-on experience is the best way to learn. This project provides a practical example of database integration.
- Boost Your Skills ๐: Improve your C++ and SQL knowledge by exploring real-world applications.
- Reusable Code โป๏ธ: The PostgreSQL class can be easily adapted for other projects requiring database interactions.
-
Clone the Repository ๐งฉ:
git clone https://github.com/siyovush-hamidov/postgresql-cpp-connector.git cd postgresql-cpp-connector
-
Install Dependencies ๐ฆ:
- Make sure you have PostgreSQL and
libpqxx
installed. - Set up your PostgreSQL server and create the
cities
table with the top 10 largest cities in the USA.
- Make sure you have PostgreSQL and
-
Compile the Code ๐ ๏ธ:
g++ -std=c++11 main.cpp PostgresDB.cpp -o connector `pkg-config --cflags --libs libpqxx`
-
Run the Program
โถ๏ธ :./city_explorer
-
Explore the Cities ๐บ๏ธ:
- Enter the city ID to see the city name.
- Type
0
to exit the program.
- https://www.postgresql.org/docs/7.2/libpqplusplus.html
- https://www.instaclustr.com/support/documentation/postgresql/using-postgresql/connecting-to-postgresql-with-c-plus-plus/
We love contributions! Feel free to fork the repository and submit pull requests. Let's make this project even better together! ๐
This project is licensed under the MIT License. See the LICENSE file for more details.