Re: Obtaining a pointer to sqlite3 handle in PyQt5's binding of QtSqlDriver - a QVariant problem
Andrej Radovic <[email protected]>
| Newsgroups | gmane.comp.python.pyqt-pykde |
|---|---|
| Message-ID | <CAOicyG37BfhwC6-p71s_VkEmc_0-kMh04J+N0-ykQ8tqbrhULQ@mail.gmail.com> |
Absolutely. Thank you! On Sat, 12 Oct 2019, 10:51 Phil Thompson, <[email protected]> wrote: > On 11/10/2019 15:23, Andrej Radovic wrote: > > Hello everyone, it's my first post here, I'll get straight to the > > point. > > > > I'm trying to register some functions in sqlite within my PyQt5 app. To > > do > > so > > within Python, I'm trying to obtain the pointer (actually, `sqlite3 > > **`) to > > the > > sqlite instance, so I could use sqlite3_create_function > > (https://sqlite.org/c3ref/create_function.html) through Python's > > `ctypes` (https://docs.python.org/3/library/ctypes.html) and register > > my > > function. > > > > When doing this in Qt5 instead of Python, you just use > > `QSqlDriver::handle()` > > (https://doc.qt.io/qt-5/qsqldriver.html#handle), which returns a > > QVariant > > containing the address. You cast the `QVariant.data()` appropriately > > and off > > you go. When I try to obtain the handle in Python , I get: > > > > db.driver().handle() > > TypeError: unable to convert a C++ 'sqlite3*' instance to a Python > > object > > > > I found that this error is generated within the C++ part of qpycore > > (qpy/QtCore/qpycore_chimera.cpp:1539). > > The code shows that a QVariant containing a pointer to an unknown type > > cannot > > be translated to a Python object. However, I don't need a Python > > object, > > just a > > pointer I can use with ctypes. > > > > Does anyone know of a way to do this? Thanks! > > In tonight's snapshot it will be converted to a voidptr object... > > > https://www.riverbankcomputing.com/static/Docs/PyQt5/api/sip/sip-module.html#voidptr > > Is that enough? > > Phil > _______________________________________________ PyQt mailing list [email protected] https://www.riverbankcomputing.com/mailman/listinfo/pyqt