Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦醒贰零壹柒
RMS
提交
ae766df8
R
RMS
项目概览
梦醒贰零壹柒
/
RMS
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
6
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
RMS
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
6
Issue
6
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
ae766df8
编写于
7月 03, 2021
作者:
梦醒贰零壹柒
提交者:
GitHub
7月 03, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #26 from mengxing2017/25-bug-clean-debug-code
25 bug clean debug code
上级
80e45c1f
baba3d5d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
31 addition
and
26 deletion
+31
-26
data.db
data.db
+0
-0
src/rms/include/db/excute_sql_file.h
src/rms/include/db/excute_sql_file.h
+1
-1
src/rms/sources/db/create_table.cpp
src/rms/sources/db/create_table.cpp
+12
-5
src/rms/sources/db/excute_sql_file.cpp
src/rms/sources/db/excute_sql_file.cpp
+17
-19
src/rms/sources/db/manage_database.cpp
src/rms/sources/db/manage_database.cpp
+1
-1
未找到文件。
data.db
已删除
100644 → 0
浏览文件 @
80e45c1f
文件已删除
src/rms/include/db/excute_sql_file.h
浏览文件 @
ae766df8
...
...
@@ -13,7 +13,7 @@
class
ExcuteSqlFile
{
public:
ExcuteSqlFile
();
int
excute
(
QFile
*
file
,
QSqlDatabase
db
);
bool
excute
(
QFile
*
file
,
QSqlDatabase
db
);
};
#endif // EXCUTE_SQL_FILE_H
src/rms/sources/db/create_table.cpp
浏览文件 @
ae766df8
#include "db/create_table.h"
#include "db/excute_sql_file.h"
#include "log.h"
#include "log4qt/logger.h"
CreateTable
::
CreateTable
()
{}
bool
CreateTable
::
CreateAccount
(
QSqlDatabase
db
)
{
// QFile file(":/res/db/create_table/create_account_table.sql");
Log4Qt
::
Logger
*
log
=
Log
::
createLog
()
->
getLogger
();
QFile
*
file
=
new
QFile
(
":/res/db/create_table/create_account_table.sql"
);
if
(
!
file
->
exists
())
{
qDebug
()
<<
"sql file not exists"
;
log
->
error
(
"sql file not exists"
)
;
file
->~
QFile
();
return
false
;
}
ExcuteSqlFile
*
excute
=
new
ExcuteSqlFile
();
if
(
0
==
excute
->
excute
(
file
,
db
))
{
qDebug
()
<<
"excute sql faild"
;
if
(
excute
->
excute
(
file
,
db
))
{
file
->~
QFile
();
log
->
error
(
"create account table success!"
);
excute
->~
ExcuteSqlFile
();
return
true
;
};
excute
->~
ExcuteSqlFile
();
file
->~
QFile
();
qDebug
()
<<
"create account table faild"
;
log
->
error
(
"create account table failed!"
)
;
return
false
;
}
src/rms/sources/db/excute_sql_file.cpp
浏览文件 @
ae766df8
...
...
@@ -5,38 +5,36 @@
ExcuteSqlFile
::
ExcuteSqlFile
()
{}
int
ExcuteSqlFile
::
excute
(
QFile
*
file
,
QSqlDatabase
db
)
{
bool
ExcuteSqlFile
::
excute
(
QFile
*
file
,
QSqlDatabase
db
)
{
Log4Qt
::
Logger
*
log
=
Log
::
createLog
()
->
getLogger
();
int
iRet
=
0
;
if
(
!
file
->
exists
())
{
return
-
1
;
log
->
error
(
"sql file not exist!"
);
return
false
;
}
if
(
!
file
->
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
))
{
return
-
1
;
log
->
error
(
"sql file open failed!"
);
return
false
;
}
if
(
db
.
isOpen
())
{
qDebug
()
<<
"excuteSqlFile: open database...."
;
db
.
open
();
}
QTextStream
in
(
file
);
in
.
setCodec
(
"UTF-8"
);
QString
sqlData
=
in
.
readAll
();
QSqlQuery
query
(
db
);
QStringList
qstrlist_sql
=
sqlData
.
split
(
";"
);
log
->
debug
(
QString
::
number
(
qstrlist_sql
.
size
()));
for
(
int
i
=
0
;
i
<
qstrlist_sql
.
size
()
-
1
;
i
++
)
{
QString
qstr_sql_part
=
qstrlist_sql
.
at
(
i
).
toUtf8
();
log
->
debug
(
qstr_sql_part
);
bool
success
=
query
.
exec
(
qstr_sql_part
);
if
(
!
success
)
{
QSqlError
lastError
=
query
.
lastError
();
QString
err
=
lastError
.
driverText
();
log
->
error
(
err
);
iRet
=
-
1
;
break
;
}
log
->
debug
(
"创建数据库表成功!"
);
QString
qstr_sql_part
=
qstrlist_sql
.
at
(
0
).
toUtf8
();
log
->
debug
(
qstr_sql_part
);
bool
success
=
query
.
exec
(
qstr_sql_part
);
if
(
!
success
)
{
QSqlError
lastError
=
query
.
lastError
();
QString
err
=
lastError
.
driverText
();
log
->
error
(
err
);
return
false
;
}
return
iRet
;
return
true
;
}
src/rms/sources/db/manage_database.cpp
浏览文件 @
ae766df8
...
...
@@ -6,7 +6,7 @@ ManageDatabase::ManageDatabase() {}
QSqlDatabase
ManageDatabase
::
connect
()
{
QSqlDatabase
db
=
QSqlDatabase
::
addDatabase
(
"QSQLITE"
);
db
.
setDatabaseName
(
":rms:"
);
db
.
setDatabaseName
(
QCoreApplication
::
applicationDirPath
()
+
"/../db/
data
.db"
);
db
.
setDatabaseName
(
QCoreApplication
::
applicationDirPath
()
+
"/../db/
rms
.db"
);
return
db
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录