<div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif">@Andrej Radovic<br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">I believe you are the poster at Qt forum a few days ago whom I told to join up here to pyqt mailing list and ask your question?</div><div class="gmail_default" style="font-family:tahoma,sans-serif">I thought it looked like you would need expert PyQt help for it.</div><div class="gmail_default" style="font-family:tahoma,sans-serif">As you can see, you get support straight from the horse's mouth here :)</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, 12 Oct 2019 at 12:08, Andrej Radovic <<a href="mailto:r.andrej@gmail.com">r.andrej@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><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" target="_blank">phil@riverbankcomputing.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);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>
_______________________________________________<br>
PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com" target="_blank">PyQt@riverbankcomputing.com</a><br>
<a href="https://www.riverbankcomputing.com/mailman/listinfo/pyqt" rel="noreferrer" target="_blank">https://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><span style="font-family:tahoma,sans-serif">Kindest,</span></div><div><span style="font-family:tahoma,sans-serif">Jonathan</span></div></div></div></div></div>