Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #73837
| Path | csiph.com!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Adam Funk <a24061@ducksburg.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Searching for lots of similar strings (filenames) in sqlite3 database |
| Date | Wed, 02 Jul 2014 13:30:08 +0100 |
| Organization | $CABAL |
| Lines | 34 |
| Message-ID | <gjad8bxpvp.ln2@news.ducksburg.com> (permalink) |
| References | <tgia8bx2sf.ln2@news.ducksburg.com> <mailman.11362.1404216365.18130.python-list@python.org> <3uva8bx3dn.ln2@news.ducksburg.com> <mailman.11375.1404230249.18130.python-list@python.org> <770d8bxunj.ln2@news.ducksburg.com> <mailman.11407.1404295399.18130.python-list@python.org> |
| Injection-Info | mx05.eternal-september.org; posting-host="11f0a8c60cd96a09a54ba99a860a92e6"; logging-data="25609"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18mXVXFMhOxcX3dZcfYL1KVkADasIQgqS4=" |
| User-Agent | slrn/pre1.0.2-9 (Linux) |
| Cancel-Lock | sha1:NoupTZjFXJdu+CbKlqjdMdZMmYE= sha1:8zt2y7Ku51vg8ckGK9uLyNPR4Ks= |
| Xref | csiph.com comp.lang.python:73837 |
Show key headers only | View raw
On 2014-07-02, Chris Angelico wrote:
> On Wed, Jul 2, 2014 at 7:32 PM, Adam Funk <a24061@ducksburg.com> wrote:
>> Well, I've changed it to the following anyway.
>>
>> subdir_glob = subdir + '/*'
>> cursor.execute('SELECT filename FROM files WHERE filename GLOB ?',
>> (subdir_glob,))
>> rows = cursor.fetchall()
>> known_files = {row[0] for row in rows}
>>
>> I see what you mean about paths containing '%', but I don't see why
>> you were concerned about underscores, though.
>
> With GLOB, presumably ? matches a single character and * matches any
> number of characters. With LIKE, _ matches a single character and %
> matches any number. So, for instance, WHERE filename LIKE
> '/foo/bar/spam_spam/%' will match '/foo/bar/spam2spam/1234', which may
> be a little surprising. It's not going to be a serious problem in most
> cases, as it'll also match '/foo/bar/spam_spam/1234', but the false
> positives will make one of those "Huhhhhh????" moments if you don't
> keep an eye on your magic characters.
>
> In your specific case, you happen to be safe, but as I look over the
> code, my paranoia kicks in and tells me to check :) It's just one of
> those things that flags itself to the mind - anything that might help
> catch bugs early is a good feature of the mind, in my opinion!
Oh, I'd just missed the '_' in the LIKE documentation. Doh!
--
Indentation is for enemy skulls, not code!
--- Klingon Programmer's Guide
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Searching for lots of similar strings (filenames) in sqlite3 database Adam Funk <a24061@ducksburg.com> - 2014-07-01 12:26 +0100
Re: Searching for lots of similar strings (filenames) in sqlite3 database Chris Angelico <rosuav@gmail.com> - 2014-07-01 22:06 +1000
Re: Searching for lots of similar strings (filenames) in sqlite3 database Adam Funk <a24061@ducksburg.com> - 2014-07-01 16:15 +0100
Re: Searching for lots of similar strings (filenames) in sqlite3 database Chris Angelico <rosuav@gmail.com> - 2014-07-02 01:57 +1000
Re: Searching for lots of similar strings (filenames) in sqlite3 database Adam Funk <a24061@ducksburg.com> - 2014-07-02 10:30 +0100
Re: Searching for lots of similar strings (filenames) in sqlite3 database Adam Funk <a24061@ducksburg.com> - 2014-07-02 10:32 +0100
Re: Searching for lots of similar strings (filenames) in sqlite3 database Chris Angelico <rosuav@gmail.com> - 2014-07-02 20:03 +1000
Re: Searching for lots of similar strings (filenames) in sqlite3 database Adam Funk <a24061@ducksburg.com> - 2014-07-02 13:30 +0100
Re: Searching for lots of similar strings (filenames) in sqlite3 database MRAB <python@mrabarnett.plus.com> - 2014-07-01 13:13 +0100
Re: Searching for lots of similar strings (filenames) in sqlite3 database Chris Angelico <rosuav@gmail.com> - 2014-07-02 00:02 +1000
csiph-web