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

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.

主站蜘蛛池模板: 绥中县| 新沂市| 曲阜市| 罗定市| 信阳市| 樟树市| 五家渠市| 祁连县| 宝鸡市| 三门峡市| 汉川市| 嘉兴市| 贵港市| 阿拉善左旗| 阜康市| 桐柏县| 子洲县| 阿拉善左旗| 桃园市| 十堰市| 南溪县| 牟定县| 扎赉特旗| 灵寿县| 汝南县| 会昌县| 廉江市| 周口市| 苏州市| 颍上县| 马鞍山市| 铁力市| 库伦旗| 凯里市| 商南县| 凤庆县| 西林县| 宿州市| 柯坪县| 昭苏县| 新干县|