Re: [PyQt] Storing QString/Unicode in Sqlite Database
On Wednesday 09 November 2011, 10:29:55 Tayfun Kayhan wrote: Thank you, the first one is working well. I tried setting API V2 but it gave an error which says that it has been already set to V1. I'll try fixing this, as well. Quoting http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/incompatible_apis.html (the link, that you got from Andrei): An application calls sip.setapi() to set the version number of a particular API. This call must be made before any module that implements the API is imported. Once set the version number cannot be changed. In short, before your very first: from PyQt4 import QtCore, QtGui Pete ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Storing QString/Unicode in Sqlite Database
Yes, this is how I wrote when I tried it. It's given the same error. What's more interesting, in another program, that I wrote and that uses unicodes, does not give any error with the same use of sip.setapi('QString', 2) . But I see a little addition code , I added : try: from PyQt4.QtCore import QString except ImportError: QString = str So this may be what prevents program from giving error. I'll try it as soon as I'm able to. Thank you. From: Hans-Peter Jansen h...@urpla.net To: pyqt@riverbankcomputing.com Sent: Wednesday, November 16, 2011 12:42 AM Subject: Re: [PyQt] Storing QString/Unicode in Sqlite Database On Wednesday 09 November 2011, 10:29:55 Tayfun Kayhan wrote: Thank you, the first one is working well. I tried setting API V2 but it gave an error which says that it has been already set to V1. I'll try fixing this, as well. Quoting http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/incompatible_apis.html (the link, that you got from Andrei): An application calls sip.setapi() to set the version number of a particular API. This call must be made before any module that implements the API is imported. Once set the version number cannot be changed. In short, before your very first: from PyQt4 import QtCore, QtGui Pete ___ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Storing QString/Unicode in Sqlite Database
Thank you, the first one is working well. I tried setting API V2 but it gave an error which says that it has been already set to V1. I'll try fixing this, as well. From: Andrei Kopats hla...@tut.by To: Tayfun Kayhan tayfun92_kay...@yahoo.com Cc: pyqt@riverbankcomputing.com pyqt@riverbankcomputing.com Sent: Wednesday, November 9, 2011 6:38 AM Subject: Re: [PyQt] Storing QString/Unicode in Sqlite Database Hi At first, you should probably use something like unicode(some_lineEdit.text(), 'utf8'), if you want to convert string to unicode. At second, for me all unicode conversion problems disappeared after I started using QString API v2. In this case, PyQt methods always return you unicode instead of QStrings http://www.riverbankcomputing.com/static/Docs/PyQt4/html/incompatible_apis.html Andrei On Wed, Nov 9, 2011 at 1:20 AM, Tayfun Kayhan tayfun92_kay...@yahoo.com wrote: Hi all, I wanna get texts from some QLineEdits' and QComboBoxes and store them in Sqlite DB. But I keep gettin the following error, i also tried using following commands that did not worked : self.info = some_lineEdit.text() self.info = str(u%s % some_lineEdit.text()) self.info = some_lineEdit.text().toUtf8() self.info = _fromUtf8(some_lineEdit.text()) sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings. Everything works fine when i don't enter unicode strings, so problem is exactly the unicode. Any help is appreciated. Thanks. ___ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Storing QString/Unicode in Sqlite Database
Hi all, I wanna get texts from some QLineEdits' and QComboBoxes and store them in Sqlite DB. But I keep gettin the following error, i also tried using following commands that did not worked : self.info = some_lineEdit.text() self.info = str(u%s % some_lineEdit.text()) self.info = some_lineEdit.text().toUtf8() self.info = _fromUtf8(some_lineEdit.text()) sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings. Everything works fine when i don't enter unicode strings, so problem is exactly the unicode. Any help is appreciated. Thanks.___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Storing QString/Unicode in Sqlite Database
Hi At first, you should probably use something like unicode(some_lineEdit.text(), 'utf8'), if you want to convert string to unicode. At second, for me all unicode conversion problems disappeared after I started using QString API v2. In this case, PyQt methods always return you unicode instead of QStrings http://www.riverbankcomputing.com/static/Docs/PyQt4/html/incompatible_apis.html Andrei On Wed, Nov 9, 2011 at 1:20 AM, Tayfun Kayhan tayfun92_kay...@yahoo.comwrote: Hi all, I wanna get texts from some QLineEdits' and QComboBoxes and store them in Sqlite DB. But I keep gettin the following error, i also tried using following commands that did not worked : self.info = some_lineEdit.text() self.info = str(u%s % some_lineEdit.text()) self.info = some_lineEdit.text().toUtf8() self.info = _fromUtf8(some_lineEdit.text()) sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings. Everything works fine when i don't enter unicode strings, so problem is exactly the unicode. Any help is appreciated. Thanks. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt