官术网_书友最值得收藏!

Database Connection

In the previous chapter, we learned how to create a login page from scratch. However, it is not functional yet, as the login page is not connected to a database. In this chapter, you will learn how to connect your Qt application to a MySQL (or MariaDB) database that validates login credentials.

In this chapter, we will cover the following topics:

  • Introducing the MySQL database system
  • Setting up the MySQL database
  • SQL commands
  • Database connection in Qt
  • Functional login page

We will walk through this chapter in a step-by-step approach to discover the powerful features that come with Qt and allow your application to connect directly to a database without any additional third-party dependencies. Database querying is a huge topic by itself, but we will be able to learn the most basic commands from scratch through examples and practical methods.

Qt supports multiple different types of database systems:

  • MySQL (or MariaDB)
  • SQLite (version 2 and 3)
  • IBM DB2
  • Oracle
  • ODBC
  • PostgreSQL
  • Sybase Adaptive Server

Two of the most popular ones are MySQL and SQLite. The SQLite database is usually used offline and it doesn't require any setup as it uses an on-disk file format for storing data. Therefore, in this chapter, we will learn how to set up a MySQL database system instead, and at the same time learn how to connect our Qt application to a MySQL database. The C++ code used to connect to the MySQL database can be reused for connecting to other database systems without many alterations.

主站蜘蛛池模板: 仪陇县| 堆龙德庆县| 澄江县| 衡阳市| 桑植县| 泗阳县| 革吉县| 忻城县| 扬州市| 邯郸市| 鹰潭市| 日土县| 石台县| 洛隆县| 奉化市| 报价| 宜宾市| 彭阳县| 吉林市| 顺昌县| 临夏市| 德昌县| 建平县| 河池市| 德阳市| 水城县| 安岳县| 康乐县| 罗甸县| 汉源县| 团风县| 陆川县| 凭祥市| 安丘市| 全南县| 阿鲁科尔沁旗| 肇源县| 金华市| 松桃| 出国| 遂宁市|