热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

使用SQLite提供可靠的用户反馈-ProvidingreliableuserfeedbackwithSQLite

ImwritinganapplicationwithaGUIfrontend(GTK)andanSQLitebackend.Whensomethingischange

I'm writing an application with a GUI frontend (GTK) and an SQLite backend. When something is changed via the GUI, I want the change to show up in the GUI if and only if it completed successfully in the DB.

我正在编写一个带有GUI前端(GTK)和SQLite后端的应用程序。当通过GUI更改某些内容时,我希望更改显示在GUI中,当且仅当它在数据库中成功完成时才会显示。

  • Is watching the return code from sqlite3_step for SQLITE_ERROR sufficient to ensure that I don't give false feedback to the user?

    从sqlite3_step看SQLITE_ERROR的返回代码是否足以确保我不向用户提供错误的反馈?

  • If not, are there other steps, such as callbacks or triggers, that would provide additional reliability?

    如果没有,是否有其他步骤,如回调或触发器,将提供额外的可靠性?

  • Is there any way to detect ALL changes to the database, rather than just ones from the program's own connection, so that I could reflect changes to its content in the GUI dynamically?

    有没有办法检测数据库的所有更改,而不仅仅是来自程序自身连接的更改,以便我可以动态地反映GUI中其内容的更改?

2 个解决方案

#1


Besides exception handling... You should reselect the data from the db that the user did commit by clicking on the save button. That way you know for sure that the user sees the right data.

除了异常处理之外......您应该通过单击“保存”按钮从用户确实提交的数据库中重新选择数据。这样您就可以确定用户看到了正确的数据。

#2


If I understand correctly you are doing a GUI application that modifies information in a SQLite db.

如果我理解正确,你正在做一个修改SQLite数据库中的信息的GUI应用程序。

  • Not really, you might get SQLITE_BUSY if you have threads; SQLITE_INTERNAL; etc. Check SQLite documentation. Instead of asking for SQLITE_ERROR you could do something like:
  • 不是真的,如果你有线程,你可能会得到SQLITE_BUSY; SQLITE_INTERNAL;检查SQLite文档。而不是要求SQLITE_ERROR你可以做类似的事情:

SQLITE_OK or SQLITE_DONE depending on what you are doing.

SQLITE_OK或SQLITE_DONE取决于您正在做什么。

if (ret != SQLITE_OK || ret != SQLITE_DONE)
    //then this is an error.
  • Don't know in what language are you coding, but I did an abstraction of SQLite in C here. You might find it interesting.

    不知道你用什么语言编写代码,但我在这里用C语言抽象了SQLite。你可能会发现它很有趣。

  • Use sqlite3_trace()


推荐阅读
author-avatar
閆小恰
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有