Re: Searching for lots of similar strings (filenames) in sqlite3 database

2014-07-02 Thread Adam Funk
On 2014-07-02, Chris Angelico wrote: > On Wed, Jul 2, 2014 at 7:32 PM, Adam Funk wrote: >> Well, I've changed it to the following anyway. >> >> subdir_glob = subdir + '/*' >> cursor.execute('SELECT filename FROM files WHERE filename GLOB ?', >>(subdir_glob,

Re: Searching for lots of similar strings (filenames) in sqlite3 database

2014-07-02 Thread Chris Angelico
On Wed, Jul 2, 2014 at 7:32 PM, Adam Funk 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() >

Re: Searching for lots of similar strings (filenames) in sqlite3 database

2014-07-02 Thread Adam Funk
On 2014-07-01, Chris Angelico wrote: > On Wed, Jul 2, 2014 at 1:15 AM, Adam Funk wrote: >> On 2014-07-01, Chris Angelico wrote: >>> There is one critical consideration, though. What happens if the >>> directory name contains an underscore or percent sign? Or can you >>> absolutely guarantee that

Re: Searching for lots of similar strings (filenames) in sqlite3 database

2014-07-02 Thread Adam Funk
On 2014-07-01, Chris Angelico wrote: > On Wed, Jul 2, 2014 at 1:15 AM, Adam Funk wrote: >> On 2014-07-01, Chris Angelico wrote: >> >>> On Tue, Jul 1, 2014 at 9:26 PM, Adam Funk wrote: cursor.execute('SELECT filename FROM files WHERE filename IS ?', (filename,)) >>> >>> Shouldn

Re: Searching for lots of similar strings (filenames) in sqlite3 database

2014-07-01 Thread Chris Angelico
On Wed, Jul 2, 2014 at 1:15 AM, Adam Funk wrote: > On 2014-07-01, Chris Angelico wrote: > >> On Tue, Jul 1, 2014 at 9:26 PM, Adam Funk wrote: >>> cursor.execute('SELECT filename FROM files WHERE filename IS ?', >>> (filename,)) >> >> Shouldn't this be an equality check rather than IS, wh

Re: Searching for lots of similar strings (filenames) in sqlite3 database

2014-07-01 Thread Adam Funk
On 2014-07-01, Chris Angelico wrote: > On Tue, Jul 1, 2014 at 9:26 PM, Adam Funk wrote: >> cursor.execute('SELECT filename FROM files WHERE filename IS ?', >> (filename,)) > > Shouldn't this be an equality check rather than IS, which normally I'd > expect to be "IS NULL" or "IS NOT NULL"

Re: Searching for lots of similar strings (filenames) in sqlite3 database

2014-07-01 Thread Chris Angelico
On Tue, Jul 1, 2014 at 10:13 PM, MRAB wrote: > Anyway, I'm sure there's something in SQL for "insert or update" or "on > duplicate", but that's an SQL question, not a Python question. Not in standard SQL, no; there might be in SQLite, as a non-standard extension, but it's a fundamentally hard pro

Re: Searching for lots of similar strings (filenames) in sqlite3 database

2014-07-01 Thread MRAB
On 2014-07-01 12:26, Adam Funk wrote: I have some code that reads files in a leafnode2 news spool & needs to check for new files periodically. The full paths are all like '/var/spool/news/message.id/345/<123...@example.com>' with a 3-digit subdirectory & a Message-ID for the filename itself. I'

Re: Searching for lots of similar strings (filenames) in sqlite3 database

2014-07-01 Thread Chris Angelico
On Tue, Jul 1, 2014 at 9:26 PM, Adam Funk wrote: > cursor.execute('SELECT filename FROM files WHERE filename IS ?', > (filename,)) Shouldn't this be an equality check rather than IS, which normally I'd expect to be "IS NULL" or "IS NOT NULL"? As to your actual question: Your two databas

Searching for lots of similar strings (filenames) in sqlite3 database

2014-07-01 Thread Adam Funk
I have some code that reads files in a leafnode2 news spool & needs to check for new files periodically. The full paths are all like '/var/spool/news/message.id/345/<123...@example.com>' with a 3-digit subdirectory & a Message-ID for the filename itself. I'm using Python 3 & sqlite3 in the standa