Code Monkey home page Code Monkey logo

asql's Introduction

Cutelyst - The Qt Web Framework Cutelyst logo

A Web Framework built on top of Qt, using the simple and elegant approach of Catalyst (Perl) framework.

Qt's meta object system is what powers the core of Cutelyst, it allows for introspecting controller's methods signatures and generate matching actions that can be invoked later.

BENCHMARKS

Don't trust us on being fast, check out the most comprehensive web framework benchmarks by TechEmpower http://www.techempower.com/benchmarks/

FEATURES:

  • Cross-platform
  • Stable API/ABI - v3 tagged from v3.x.x, v2 tags, v1 on v1.x.x branch (unmaintained)
  • Pluggable Engines
    • Cutelyst::Server - A cross-platform and fast server engine
      • HTTP/1.1 - Pipelining and Keep-Alive
      • HTTP/2 - Upgrade to H2, ALPN negotiation on HTTPS and direct H2C
      • FastCGI - Pipelining and Keep-Alive
  • WebSockets
  • REST with ActionREST
  • Plugin based views
    • Cutelee (A Qt implementation of Django's template engine)
    • JSON
    • Email
  • Dispatcher
    • Chained
    • Path
  • Plugins
    • Session
    • Authentication (with PBKDF2)
    • Authorization with RoleACL
    • StatusMessage
    • Validator (to validate user input)
    • CSRF protection
    • Memcached
    • UserAgent
  • Asynchronous processing (just don't use local QEventLoops or it will eventually crash)
    • Async SQL with ASql
  • Upload parser
  • JSON body as QJsonDocument when uploaded data is in JSON format
  • C++20
  • Chunked reponses (via QIODevice write API)
  • Request profiling/stats
  • Unit tested
  • QtCreator integration

DOCUMENTATION

Get started with our Tutorial or check the API.

COMMUNITY

Mailing List

REQUIREMENTS

  • CMake - for the build system (>= 3.16)
  • Qt - the core library of this framework (>= 6.2)

LICENSE

The source code is available is under the 3-Clause BSD.

asql's People

Contributors

adriaandegroot avatar andreagen0r avatar dantti avatar xvjau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

asql's Issues

Question: Is database username and password easy to grab?

What mechanism is used to protect username/password from extracting text strings from the executable and is there an SSL encrypted connection between the app and the xxSQL server to prevent the man-in-middle attack?

RE:
`APool::create(APg::factory("postgres://user:pass@server/dbname?target_session_attrs=read-write"));
APool::create(APg::factory("postgres://user:pass@server/dbname"), "my_read_only_pool");

`

Has Asql any public function to validate query parameters outside of db.exec?

Sometimes I would like to create query with some requests parameters in place where I cannot create query prepared parameter, like table name or order by (where prepared parameter is not working).
It will be useful and safe if I can validate such request parameter if it not contains any tables or database drops and other strange things.

ASql setNumericalPrecisionPolicy

Is there an equivalent of (setNumericalPrecisionPolicy) in ASql?

//pseudo code
QSqlQuery q();
q.setNumericalPrecisionPolicy(QSql::HighPrecision);

we use the above to return columns having "numeric" data type in the database as TEXT cuz we want to keep high precision (16 decimal places and in some cases 50 decimals). We are using types from the boost arbitrary precision library to store and handle the values in C++ instead of using the native double type.

db.exec on a disconnected database

Hi,

When my cutelyst instance has some database troubles, the coming requests looks "stalled" somewhere.

Even when the database connection is established after all, the previous pending requests are not executed.

Is there a way to handle database states with asql to avoid this behavior ?

Step to reproduce :

  • start a sample cutelyst application
  • make a request (which should be fine!)
  • disconnect the database (e.g: /etc/init.d/postgres stop)
  • make a request
  • the cutelyst application is stalled
  • restore the database (e.g: /etc/init.d/postgres start)
  • the request is still on hold.

Here is my sample controller :

void test::index(Context *c)
{
    auto db = APool::database();
    ASync a(c);

    db.exec("select now()",
            {},
            [a, c] (AResult &result) {
                if (result.error()) {
                    c->response()->body() = result.errorString().toUtf8();
                    c->response()->setStatus(500);
                }
                c->response()->body() = result[0][0].toString().toUtf8();
            });
}

I would expect ;

  • having result.error() triggered when database is not available ,
  • or having an executed request if the database state is changed to "Connected"

Executable names with Qt5 and Qt6

I open this issue only here, because I will start with asql as it is smaller than cutelyst, but issue is the same. :)

Now that there is / will be support for two versions of Qt it would be nice to have the used version of Qt in the executable names, too. Otherwise one would have file conflicts with having packages installed for both versions of Qt. So, e.g. for asql there is the asql-migration executable. My proposal would be to add a Qt version suffix like -qt5 and -qt6. Same would than have to be done for the cutelyst executables.

I could for sure also only patch my distribution packages but would be then out of line with the upstream naming. :)

Table name as query parameter?

I try to perform this:

ASql::APool::database().exec(u"SELECT * FROM $1", {table_name},
[a, c, table_name](ASql::AResult &result) {...}

and in result I got error
ERROR: syntax error at or near "$1"\nLINE 1: SELECT * FROM $1\n

Seems like parameter $1 is not resolved with table_name.
Limitation or bug?

general question

Is it possible to address the problem of async at the sql drivers plugins implementation level of the standard Qt ?

Compilation error

When trying to compile the current code, I get the following error: (ok, it is the linker, not the compiler)

[   61s] [ 71%] Linking CXX shared library libASqlQt6Pg.so
[   61s] cd "/home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/build/src" && /usr/bin/cmake -E cmake_link_script CMakeFiles/ASqlQt6Pg.dir/link.txt --verbose=1
[   61s] /usr/bin/c++ -fPIC -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -DNDEBUG -O2 -g -DNDEBUG -flto=auto -Wl,--as-needed -Wl,--no-undefined -Wl,-z,now -shared -Wl,-soname,libASqlQt6Pg.so.0 -o libASqlQt6Pg.so.0.50.0 CMakeFiles/ASqlQt6Pg.dir/ASqlQt6Pg_autogen/mocs_compilation.cpp.o CMakeFiles/ASqlQt6Pg.dir/adriverpg.cpp.o CMakeFiles/ASqlQt6Pg.dir/apg.cpp.o  /usr/lib64/libQt6Core.so.6.2.1 /usr/lib64/libpq.so 
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans0.ltrans.o: in function `AResultPg::~AResultPg()':
[   61s] /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.cpp:735: undefined reference to `AResultPrivate::~AResultPrivate()'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans0.ltrans.o: in function `std::_Function_handler<void (AResult&), ADriverPg::unsubscribeFromNotification(std::shared_ptr<ADriver> const&, QString const&)::{lambda(AResult&)#1}>::_M_invoke(std::_Any_data const&, AResult&)':
[   61s] /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.cpp:422: undefined reference to `AResult::error() const'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans0.ltrans.o:/home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.cpp:422: undefined reference to `AResult::errorString() const'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans0.ltrans.o: in function `ADriverPg::open(std::function<void (bool, QString const&)>)':
[   61s] /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.cpp:99: undefined reference to `ADriver::connectionInfo() const'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.cpp:101: undefined reference to `ADriver::connectionInfo() const'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans0.ltrans.o: in function `ADriverPg::~ADriverPg()':
[   61s] /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriver.h:26: undefined reference to `vtable for ADriver'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans0.ltrans.o: in function `std::_Function_handler<void (AResult&), ADriverPg::subscribeToNotification(std::shared_ptr<ADriver> const&, QString const&, std::function<void (ADatabaseNotification const&)>, QObject*)::{lambda(AResult&)#1}>::_M_invoke(std::_Any_data const&, AResult&)':
[   61s] /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.cpp:402: undefined reference to `AResult::error() const'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans0.ltrans.o:/home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.cpp:402: undefined reference to `AResult::errorString() const'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans0.ltrans.o:/home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.cpp:403: undefined reference to `AResult::error() const'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans0.ltrans.o: in function `APGQuery::done()':
[   61s] /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.h:77: undefined reference to `AResult::AResult(std::shared_ptr<AResultPrivate> const&)'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.h:81: undefined reference to `AResult::~AResult()'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans0.ltrans.o: in function `ADriverPg::doExec(APGQuery&)':
[   61s] /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.cpp:484: undefined reference to `APreparedQuery::identification() const'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.cpp:486: undefined reference to `APreparedQuery::identification() const'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.cpp:499: undefined reference to `APreparedQuery::query() const'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.cpp:498: undefined reference to `APreparedQuery::identification() const'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans0.ltrans.o: in function `ADriverPg::doExecParams(APGQuery&)':
[   61s] /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.cpp:662: undefined reference to `APreparedQuery::identification() const'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.cpp:664: undefined reference to `APreparedQuery::identification() const'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.cpp:677: undefined reference to `APreparedQuery::query() const'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.cpp:676: undefined reference to `APreparedQuery::identification() const'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans0.ltrans.o: in function `ADriverPg::exec(std::shared_ptr<ADriver> const&, QString const&, QList<QVariant> const&, std::function<void (AResult&)>, QObject*)':
[   61s] /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.h:63: undefined reference to `APreparedQuery::APreparedQuery()'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans0.ltrans.o: in function `ADriverPg::exec(std::shared_ptr<ADriver> const&, QStringView, QList<QVariant> const&, std::function<void (AResult&)>, QObject*)':
[   61s] /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.h:63: undefined reference to `APreparedQuery::APreparedQuery()'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans0.ltrans.o: in function `ADriverPg::exec(std::shared_ptr<ADriver> const&, APreparedQuery const&, QList<QVariant> const&, std::function<void (AResult&)>, QObject*)':
[   61s] /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.h:63: undefined reference to `APreparedQuery::APreparedQuery()'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans0.ltrans.o: in function `ADriverPg::open(std::function<void (bool, QString const&)>)::{lambda()#3}::operator()() const [clone .lto_priv.0]':
[   61s] /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.cpp:200: undefined reference to `APreparedQuery::identification() const'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans0.ltrans.o: in function `AResultPg::~AResultPg()':
[   61s] /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.cpp:735: undefined reference to `AResultPrivate::~AResultPrivate()'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.cpp:735: undefined reference to `AResultPrivate::~AResultPrivate()'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans0.ltrans.o: in function `ADriverPg::qt_metacast(char const*)':
[   61s] /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/build/src/ASqlQt6Pg_autogen/include/moc_adriverpg.cpp:89: undefined reference to `ADriver::qt_metacast(char const*)'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans0.ltrans.o: in function `ADriverPg::qt_metacall(QMetaObject::Call, int, void**)':
[   61s] /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/build/src/ASqlQt6Pg_autogen/include/moc_adriverpg.cpp:94: undefined reference to `ADriver::qt_metacall(QMetaObject::Call, int, void**)'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans0.ltrans.o: in function `APGQuery::done()':
[   61s] /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.h:81: undefined reference to `AResult::~AResult()'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans0.ltrans.o:(.data.rel.ro+0x38): undefined reference to `typeinfo for AResultPrivate'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans0.ltrans.o:(.data.rel.ro+0x68): undefined reference to `typeinfo for ADriver'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans0.ltrans.o:(.data.rel.ro+0xa0): undefined reference to `ADriver::staticMetaObject'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans0.ltrans.o:(.data.rel.ro+0x128): undefined reference to `AResultPrivate::indexOfField(QString const&) const'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans0.ltrans.o:(.data.rel.ro+0x130): undefined reference to `AResultPrivate::indexOfField(QStringView) const'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans1.ltrans.o: in function `APg::createRawDriver() const':
[   61s] /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.cpp:54: undefined reference to `ADriver::ADriver(QString const&)'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans1.ltrans.o: in function `APg::createDriver() const':
[   61s] /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.cpp:54: undefined reference to `ADriver::ADriver(QString const&)'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans1.ltrans.o: in function `APg::createDatabase() const':
[   61s] /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.cpp:54: undefined reference to `ADriver::ADriver(QString const&)'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans1.ltrans.o: in function `APg::createDatabase() const':
[   61s] /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/apg.cpp:51: undefined reference to `ADatabase::ADatabase(std::shared_ptr<ADriver> const&)'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans1.ltrans.o: in function `APg::APg(QString const&)':
[   61s] /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/apg.cpp:15: undefined reference to `ADriverFactory::ADriverFactory()'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans1.ltrans.o: in function `APg::database(QString const&)':
[   61s] /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/apg.cpp:33: undefined reference to `ADatabase::ADatabase(std::shared_ptr<ADriverFactory> const&)'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans1.ltrans.o: in function `std::_Sp_counted_ptr_inplace<AResultPg, std::allocator<AResultPg>, (__gnu_cxx::_Lock_policy)2>::_M_dispose()':
[   61s] /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.cpp:735: undefined reference to `AResultPrivate::~AResultPrivate()'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans1.ltrans.o:/home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/adriverpg.cpp:735: undefined reference to `AResultPrivate::~AResultPrivate()'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans1.ltrans.o: in function `APg::~APg() [clone .localalias]':
[   61s] /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/apg.cpp:23: undefined reference to `ADriverFactory::~ADriverFactory()'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans1.ltrans.o: in function `std::_Sp_counted_ptr_inplace<APg, std::allocator<APg>, (__gnu_cxx::_Lock_policy)2>::_M_dispose()':
[   61s] /home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/src/apg.cpp:23: undefined reference to `ADriverFactory::~ADriverFactory()'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans1.ltrans.o: in function `APg::APg(QString const&)':
[   61s] /usr/include/c++/11/ext/new_allocator.h:145: undefined reference to `ADriverFactory::~ADriverFactory()'
[   61s] /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/bin/ld: /tmp/ccsiGsMc.ltrans1.ltrans.o:(.data.rel.ro+0x40): undefined reference to `typeinfo for ADriverFactory'
[   61s] collect2: error: ld returned 1 exit status
[   61s] make[2]: *** [src/CMakeFiles/ASqlQt6Pg.dir/build.make:134: src/libASqlQt6Pg.so.0.50.0] Error 1
[   61s] make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/asql-0.50.60~git1637889808.c43b1d2/build'
[   61s] make[1]: *** [CMakeFiles/Makefile2:136: src/CMakeFiles/ASqlQt6Pg.dir/all] Error 2
[   61s] make[1]: *** Waiting for unfinished jobs....

Including ASql libs in Cutelyst app

I build and install ASql library in my Ubuntu system and try to include it in my Cutelyst application.
My application is build with qmake, so in my .pro file I add
INCLUDEPATH+=
/usr/include/cutelyst3-qt5
/usr/include/asql-qt5

LIBS += -lCutelyst3Qt5 -lASqlQt5 -lASqlQt5Pg

and when I add imports to my cpp file (like in all examles I have found)

#include <apool.h>
#include <apg.h>

both are not found.
Same if with quotes.

If I add

#include "asql-qt5/ASql/apool.h"
#include "asql-qt5/ASql/apg.h"

both are found, but further compile errors occurs:

/usr/local/include/asql-qt5/ASql/apool.h:12: błąd: adatabase.h: No such file or directory
In file included from ../UnagiBackend/src/unagibackend.cpp:14:
/usr/local/include/asql-qt5/ASql/apool.h:12:10: fatal error: adatabase.h: No such file or directory
12 | #include <adatabase.h>

Suspicious ")", "tabsle" and more

Hello. If I were you I would look at the examples seen on https://github.com/cutelyst/asql/ because there are some suspicious ")" :
- db.exec("SELECT id, message FROM messages LIMIT 5"), [=] [...]
- db.exec("SELECT pg_sleep(5)"), [=] [...]
- possibly more
and some "tabsle".

I suppose that more little bugs will exists, because I really haven't tested the code, just skimmed it. And I wanted to thank you for Asql :-)

libpq is libpqxx on redhat/centos

In order to configure the project with cmake on redhat/centos I had to use the following patch:-

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e520d8e..cb44174 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,7 +6,7 @@ include(GNUInstallDirs)
 find_package(PkgConfig REQUIRED)

 # Postgres library
-pkg_check_modules(LIBPQ REQUIRED libpq)
+pkg_check_modules(LIBPQ REQUIRED libpqxx)

 set(CMAKE_AUTOMOC ON)

query with integer[] array

Hi
We are trying to use Cutelyst in web projects. So far I have been using QHttpEngine in Qt servers and would like to switch to Cutelyst with ASql library, so first of all:
Thank You for your work.

I'm trying to make a query which inserts into a table where column is int array

      Table "public.test"
 Column |   Type    | Modifiers 
--------+-----------+-----------
 a      | integer[] | 

So query would be:
insert into test (a) values ('{1,2}');

And I'm trying with code:

    QString queryStr = QStringLiteral("insert into test (a) values ($1)")
    QList<QVariant> role;
    role <<QVariant(3)<<QVariant(4);
    QVariantList myList;
    myList << QVariant(role);
    qDebug()<<"myList: "<<myList;

    ASql::APool::database().exec(queryStr,myList, [=] (ASql::AResult &result) {

it gives output:

myList:  (QVariant(QVariantList, (QVariant(int, 3), QVariant(int, 4))))
LOG:  execute <unnamed>: insert into test (a) values ($1)
DETAIL:  parameters: $1 = NULL

So the parameter is always NULL, we have tried different options... , how to setup myList for this ?

Best Regards
Marek

How to prepare value for column of integer[] type

Any QVariant I try to prepare I got query exec errors like
ERROR: null value in column "xxx" violates not-null constraint
or
ERROR: column "xxx" is of type integer[] but expression is of type jsonb

I got values from QJsonObject where data for int[] columnt is in QJsonArray and I ahve only problem with this column.
How I must prepare QVariant from QJsonArray so it fit integer[] format?

Using ASql with sync mode?

Is there any possibility to use ASql in sync mode?
Why? Because I would like to have simple queries return result immediately to my code, so I can use it as return value of function.
So... can I achieve this with ASql or I must to use standard QSql class and mix it with ASql usage?

HELP needed: transaction when calling many functions with queries

I have quite complicated routines in my Cutelyst/Asql based application.
In few places there is stream of calls like this:
ASql::APool::database().exec(....,[=]((ASql::AResult &result){
if (!result.error()) {
....
SomeNextFunction(c, result, [=](Context *c, QJsonArray res) {
....
});
}
}
When you surround this with ATransaction t it is easy to pass t as lambda parameter.
But if SomeNextFunction contains inside another call of ASql::APool::database().exec (prepend by Async a(c)) it seems transaction is not rolling back changes made by SomeNextFunction.

Is there any way to rolling back all queries automatically?
Am I doing this wrong way?

Feature Request: more detailed info for multiqueries

If I post multiple queries in one string I dont get any information which one is executed, which one cause error etc.
At least I want to get index of current query I can identify which one is current from my list.

Feature Request: ad field like QSqlQuery ASql::AResult::lastExecutedQuery

It would be useful to have in ASql::AResult access to last executed query.
If I have multiple queries send in one ASql::APool::database().exec then when I check each result I cant get query which caused error.
Sometimes result.errorString() is not enough...
If you think QSqlQuery is too big object to add it to ASql::AResult (or for other reasons) then at least you can add just executed query string.

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.