C++ and Databases: A Practical Guide
300 pages
English
PDF
4.5

C++ and Databases: A Practical Guide

C++ and Databases: A Practical Guide

Author:

Year:

Summary:

The book "C++ and Databases: A Practical Guide" is a comprehensive resource for developers who want to master integrating the C++ language with modern relational databases. The material covers all stages: from writing your first SQL queries to creating high-load systems with connection pools and caching.



The author systematically covers working with three popular DBMS: MySQL, PostgreSQL, and SQLite. You will learn how to connect to databases, execute queries, handle errors, and manage transactions. Special attention is paid to performance: configuring indexes, optimizing slow queries, and profiling.



Who is this book for?

  • Junior+ and Middle C++ developers who want to add database skills to their toolkit.
  • Backend engineers transitioning to C++ from other languages (Java, Python, C#) — the chapters on SQL and transactions are written from scratch.
  • Technical students studying systems programming.


What will you learn?

  • How to use the libpqxx (PostgreSQL), mysql-connector-c++, and sqlite3 libraries.
  • Implementing an ORM-like layer manually: mapping C++ structures to database tables.
  • Patterns for working with a connection pool (Connection Pool) and resource reuse.
  • Error handling, transaction rollback, and protection against SQL injection.
  • Asynchronous queries using std::future and boost::asio.


At the end of the book, you will find two complete projects: a console task manager (SQLite) and a microservice in C++ with a REST API and data storage in PostgreSQL. All code examples are available in a GitHub repository and have been tested on Linux, Windows, and macOS.



"C++ and Databases" is not an SQL reference, but a practical tool for those who want to write reliable, fast, and secure code that works with real data. The book is suitable both for self-study and for use as a desktop reference.

Recommendations