Re: [sqlite] How to search column ascii containing chr(0)
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 06/05/2011 12:20 AM, iip wrote: > As subject, I want to know how search column that contain ascii chr(0), I > already use google to search but no luck, > > I'm using python language. If you are using APSW then you can define a user defined function which will work fine: def hasnull(s): return "\x00" in s This won't work with pysqlite because it doesn't handle nulls in strings. Roger -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (GNU/Linux) iEYEARECAAYFAk3rtsgACgkQmOOfHg372QT5nwCfX0T2jhWWHcHDx9tdd7tZGMVF qfcAoJ8NgSSAno9v3YhIEIzwIpQ9CD5Q =1nqN -END PGP SIGNATURE- ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] How to search column ascii containing chr(0)
Robert Myerswrote: > On 6/5/2011 8:47 AM, Igor Tandetnik wrote: >> iip wrote: >>> As subject, I want to know how search column that contain ascii chr(0) >> select * from MyTable where hex(MyField) like '%00%'; > > That query doesn't work. If the field contains 0\n, that would match (300A) True. Another attempt: select * from MyTable where 2*length(MyField) != length(hex(MyField)); This relies on the fact that built-in function length() seems to stop (erroneously, in my opinion) on the first embedded NUL, while hex() doesn't seem to mind them. At least that's what happens with my copy of SQLite 3.7.2. Beyond this nasty hack, I can't think of anything short of writing a custom function. I tried LIKE and replace() - they don't work with embedded NULs either. -- Igor Tandetnik ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] How to search column ascii containing chr(0)
On Sun, Jun 5, 2011 at 8:47 PM, Igor Tandetnikwrote: > iip wrote: > > As subject, I want to know how search column that contain ascii chr(0) > > select * from MyTable where hex(MyField) like '%00%'; > > -- > Igor Tandetnik > yes, I already did that, so there are no other way that more efficient than this one right? because I'm still have to add separator to avoid wrong catch just like '100D' -> '10-0D'. Thank a lot, -iip- ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] How to search column ascii containing chr(0)
On 6/5/2011 8:47 AM, Igor Tandetnik wrote: > iipwrote: >> As subject, I want to know how search column that contain ascii chr(0) > select * from MyTable where hex(MyField) like '%00%'; That query doesn't work. If the field contains 0\n, that would match (300A) ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] How to search column ascii containing chr(0)
iipwrote: > As subject, I want to know how search column that contain ascii chr(0) select * from MyTable where hex(MyField) like '%00%'; -- Igor Tandetnik ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] How to search column ascii containing chr(0)
Hi All, As subject, I want to know how search column that contain ascii chr(0), I already use google to search but no luck, I'm using python language. Thanks in advance, -iip- ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users