当前位置:网站首页>QT使用sqllite
QT使用sqllite
2022-07-02 02:23:00 【NLeRnotfalled】
sql.pro目录里面,加入sql的支持
QT += core gui
QT += sql
为了防止生成到debug文件,需要在database名加入…/+“你的工程目录”/数据库名的运算符,使得.db文件生成在你的工程目录里
#include "mainwindow.h"
#include <QApplication>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QDebug>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("../sql/test.db");
db.open();
QString path = QCoreApplication::applicationDirPath();
qDebug()<<path;
QSqlQuery query;
query.exec("CREATE TABLE student(id INT PRIMARY KEY, username VARCHAR(30),pwd VARCHAR(30))");
MainWindow w;
w.show();
qDebug()<<QSqlDatabase::drivers();
return a.exec();
}
边栏推荐
- pytest 测试框架
- query词权重, 搜索词权重计算
- Start from scratch - Web Host - 01
- how to come in an investnent bank team
- 2022 low voltage electrician test question simulation test question bank simulation test platform operation
- JVM interview
- Leetcode face T10 (1-9) array, ByteDance interview sharing
- 花一个星期时间呕心沥血整理出高频软件测试/自动化测试面试题和答案
- leetcode2309. 兼具大小写的最好英文字母(简单,周赛)
- [learn C and fly] 4day Chapter 2 program in C language (exercise 2.5 generate power table and factorial table
猜你喜欢
附加:信息脱敏;
If you want to rewind the video picture, what simple methods can you use?
Software No.1
超图iServer rest服务之feature查询
[opencv] - comprehensive examples of five image filters
LFM信号加噪、时频分析、滤波
【带你学c带你飞】3day第2章 用C语言编写程序(练习 2.3 计算分段函数)
LeetCode刷题(十)——顺序刷题46至50
大厂裁员潮不断,双非本科出身的我却逆风翻盘挺进阿里
Word search applet design report based on cloud development +ppt+ project source code + demonstration video
随机推荐
Leetcode face T10 (1-9) array, ByteDance interview sharing
Deep learning: a solution to over fitting in deep neural networks
剑指 Offer 29. 顺时针打印矩阵
大厂裁员潮不断,双非本科出身的我却逆风翻盘挺进阿里
[learn C and fly] 3day Chapter 2 program in C language (exercise 2.3 calculate piecewise functions)
剑指 Offer 47. 礼物的最大价值
If you want to rewind the video picture, what simple methods can you use?
2022 Q2 - Summary of skills to improve skills
Build a modern data architecture on the cloud with Amazon AppFlow, Amazon lake formation and Amazon redshift
Oracle creates a user with read-only permission in four simple steps
Vsocde has cli every time it is opened js
The middle element and the rightmost element of the shutter
What are the necessary things for students to start school? Ranking list of Bluetooth headsets with good sound quality
研发中台拆分过程的一些心得总结
leetcode2305. Fair distribution of biscuits (medium, weekly, shaped pressure DP)
trading
LFM信号加噪、时频分析、滤波
What is the function of the headphone driver
【带你学c带你飞】4day第2章 用C语言编写程序(练习 2.5 生成乘方表与阶乘表
STM32F103——两路PWM控制电机