SQL Programming
This overview assumes that you have at least a basic knowledge of SQL. You should be able to understand simple SELECT, INSERT, UPDATE, and DELETE statements. Although the QSqlTableModel class provides an interface to database browsing and editing that does not require a knowledge of SQL, a basic understanding of SQL is highly recommended. A standard text covering SQL databases is An Introduction to Database Systems (7th Ed.) by C. J. Date, ISBN 0201385902.
本概述假设您至少具备SQL的基本知识。您应该能够理解简单的SELECT、INSERT、UPDATE和DELETE语句。尽管QSqlTableModel类为数据库浏览和编辑提供了一个不需要SQL知识的界面,但强烈建议您对SQL有基本的了解。涵盖SQL数据库的标准文本是C.J.Date的《数据库系统导论》(第7版),ISBN 0201385902。
Topics:
话题:
数据库类
连接到数据库
SQL数据库驱动程序
执行SQL语句
支持Qt的数据库系统的数据类型
使用SQL模型类
在表视图中显示数据
创建数据感知表单
Database Classes
数据库类
These classes provide access to SQL databases.
这些类提供对SQL数据库的访问。
Contains miscellaneous identifiers used throughout the Qt SQL module 包含整个Qt SQL模块中使用的杂项标识符 | |
Handles a connection to a database 处理与数据库的连接 | |
Abstract base class for accessing specific SQL databases 用于访问特定SQL数据库的抽象基类 | |
Template class that provides a SQL driver factory for a specific driver type 为特定驱动程序类型提供SQL驱动程序工厂的模板类 | |
The base class for SQL driver factories SQL驱动程序工厂的基类 | |
SQL database error information SQL数据库错误信息 | |
Manipulates the fields in SQL database tables and views 操作SQL数据库表和视图中的字段 | |
Functions to manipulate and describe database indexes 操作和描述数据库索引的函数 | |
Means of executing and manipulating SQL statements 执行和操作SQL语句的方法 | |
Read-only data model for SQL result sets SQL结果集的只读数据模型 | |
Encapsulates a database record 封装数据库记录 | |
Editable data model for a single database table, with foreign key support 单个数据库表的可编辑数据模型,支持外键 | |
Abstract interface for accessing data from specific SQL databases 用于访问特定SQL数据库中的数据的抽象接口 | |
Editable data model for a single database table 单个数据库表的可编辑数据模型 |
The SQL classes are divided into three layers:
SQL类分为三层:
Driver Layer
驱动层
This comprises the classes QSqlDriver, QSqlDriverCreator, QSqlDriverCreatorBase, QSqlDriverPlugin, and QSqlResult.
这包括类QSqlDriver、QSqlDriverCreator、QSqlDRIVECreatorBase、QSqldrivePlugin和QSqlResult。
This layer provides the low-level bridge between the specific databases and the SQL API layer. See SQL Database Drivers for more information.
该层提供了特定数据库和SQLAPI层之间的低级桥梁。有关详细信息,请参阅SQL数据库驱动程序。
SQL API Layer
SQL API层
These classes provide access to databases. Connections are made using the QSqlDatabase class. Database interaction is achieved by using the QSqlQuery class. In addition to QSqlDatabase and QSqlQuery, the SQL API layer is supported by QSqlError, QSqlField, QSqlIndex, and QSqlRecord.
这些类提供对数据库的访问。使用QSqlDatabase类进行连接。数据库交互是通过使用QSqlQuery类来实现的。除了QSqlDatabase和QSqlQuery之外,QSqlError、QSqlField、QSqlIndex和QSqlRecord还支持SQL API层。
User Interface Layer
用户接口层
These classes link the data from a database to data-aware widgets. They include QSqlQueryModel, QSqlTableModel, and QSqlRelationalTableModel. These classes are designed to work with Qt's model/view framework.
这些类将数据库中的数据链接到数据感知小部件。它们包括QSqlQueryModel、QSqlTableModel和QSqlRelationalTableModel。这些类被设计用于与Qt的模型/视图框架一起工作。
Note that a QCoreApplication object must be instantiated before using any of these classes.
请注意,在使用这些类之前,必须实例化QCoreApplication对象。
连接到数据库
© 2023 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.
本文介绍了Qt框架中与SQL编程相关的类和概念,包括QSqlDatabase用于数据库连接,QSqlQuery执行SQL语句,以及QSqlTableModel等数据模型类用于数据呈现和编辑。文章强调了即使有QSqlTableModel这样的抽象接口,了解基础SQL知识仍然是重要的。同时,文章涵盖了数据库类的三层结构:驱动层、SQLAPI层和用户接口层。
861

被折叠的 条评论
为什么被折叠?



