Git Product home page Git Product logo

msqlquery's Introduction

Build Status

MSqlQuery

An asynchronous interface to use functions in the Qt5 SQL module

demo screenshot1

demo screenshot2

  • Include The .pri file in your project, and use MSqlQuery classes (starting with letter M instead of Q), they provide a similar interface to their equivalent classes in Qt, in addition to execAsync() function , which executes a query asynchronously and emits a signal when done.

  • Also, there is an MSqlQueryModel class, that provides the same interface of QSqlQueryModel, in addition to setQueryAsync() which returns immediately, and the model is reset later when the query actually returns

  • You can take a look at the msqlquery-demo.pro project for a quick demo on how to use the classes in this project

  • Support for the notifications system

  • The Whole Thing Works By Moving all database operations, to a single thread per connection. Only one thread per connection is used because a database connection can be used from the thread that creates it only (a limitation in the Qt5 SQL module)

  • As A consequence to the previous point , you can't use the Qt Classes (QSqlQuery, QSqlDatabase, QSqlQueryModel, ..) directly when using MSqlQuery classes on the same connection. because Qt classes will try to access the database connection from a Thread Other the one that created it.

  • That is why synchronous functions exist in MSqlQuery classes (they have the same names of the corresponding functions in Qt), they even behave exactly the same as their Qt equivalents (as they just call them in the database thread behind the scenes).

  • The asynchronous functions's names end with *Async(), eg.: execAsync(), setQueryAsync(), ...

  • Better Readme coming soon, feel free to contact me ( [email protected] ) for more information


Note:

todo list:

  • get rid of the MDbWorker class, and use lambda functions instead of its slots.
  • get rid of the singleton db thread, and use a separate thread for each database connection.
  • use std::future or QFuture to properly encapsulate asynchronous operations.
  • write documentation and a better readme.
  • add support for batch queries.
  • add a class to encapsulate several transactional SQL queries asynchronously.

msqlquery's People

Contributors

micjabbour avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.