<div dir="auto">Absolutely. Thank you!</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, 12 Oct 2019, 10:51 Phil Thompson, <<a href="mailto:phil@riverbankcomputing.com">phil@riverbankcomputing.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 11/10/2019 15:23, Andrej Radovic wrote:<br>
> Hello everyone, it's my first post here, I'll get straight to the <br>
> point.<br>
> <br>
> I'm trying to register some functions in sqlite within my PyQt5 app. To <br>
> do<br>
> so<br>
> within Python, I'm trying to obtain the pointer (actually, `sqlite3 <br>
> **`) to<br>
> the<br>
> sqlite instance, so I could use sqlite3_create_function<br>
> (<a href="https://sqlite.org/c3ref/create_function.html" rel="noreferrer noreferrer" target="_blank">https://sqlite.org/c3ref/create_function.html</a>) through Python's<br>
> `ctypes` (<a href="https://docs.python.org/3/library/ctypes.html" rel="noreferrer noreferrer" target="_blank">https://docs.python.org/3/library/ctypes.html</a>) and register <br>
> my<br>
> function.<br>
> <br>
> When doing this in Qt5 instead of Python, you just use<br>
> `QSqlDriver::handle()`<br>
> (<a href="https://doc.qt.io/qt-5/qsqldriver.html#handle" rel="noreferrer noreferrer" target="_blank">https://doc.qt.io/qt-5/qsqldriver.html#handle</a>), which returns a <br>
> QVariant<br>
> containing the address. You cast the `QVariant.data()` appropriately <br>
> and off<br>
> you go. When I try to obtain the handle in Python , I get:<br>
> <br>
>     db.driver().handle()<br>
>     TypeError: unable to convert a C++ 'sqlite3*' instance to a Python<br>
> object<br>
> <br>
> I found that this error is generated within the C++ part of qpycore<br>
> (qpy/QtCore/qpycore_chimera.cpp:1539).<br>
> The code shows that a QVariant containing a pointer to an unknown type<br>
> cannot<br>
> be translated to a Python object. However, I don't need a Python <br>
> object,<br>
> just a<br>
> pointer I can use with ctypes.<br>
> <br>
> Does anyone know of a way to do this? Thanks!<br>
<br>
In tonight's snapshot it will be converted to a voidptr object...<br>
<br>
<a href="https://www.riverbankcomputing.com/static/Docs/PyQt5/api/sip/sip-module.html#voidptr" rel="noreferrer noreferrer" target="_blank">https://www.riverbankcomputing.com/static/Docs/PyQt5/api/sip/sip-module.html#voidptr</a><br>
<br>
Is that enough?<br>
<br>
Phil<br>
</blockquote></div>