Page 1 of 1

FF history & sqlite

Posted: Wed Oct 14, 2009 1:57 pm
by Fender
I'm trying to replace all my q3f history w/ q3w history, but failing.

Querying works:
sqlite3 places.sqlite "select url from moz_places where url like '%quake3forum%'"
(big list of q3f URLs)

But updating does not:
sqlite3 places.sqlite "update moz_places set url=replace(url,'quake3forum','quake3world') where url like '%quake3forum%'"

That fails w/ this error message:
SQL error: column url is not unique

I'm guessing there's a unique index on URL, and that update would cause a integrity violation. Does anyone know of a way to make sqlite ignore errors on a per row basis and continue on with the reset of the result set?

Re: FF history & sqlite

Posted: Wed Oct 14, 2009 2:39 pm
by ^misantropia^

Re: FF history & sqlite

Posted: Wed Oct 14, 2009 6:33 pm
by Fender
That would be awesome if it worked. I tried:

update on conflict replace moz_places set url=replace(url,'quake3forum','quake3world') where url like '%quake3forum%'
update moz_places on conflict replace set url=replace(url,'quake3forum','quake3world') where url like '%quake3forum%'
update moz_places set url=replace(url,'quake3forum','quake3world') on conflict replace where url like '%quake3forum%'
update moz_places set url=replace(url,'quake3forum','quake3world') where url like '%quake3forum%' on conflict replace

And they all gave me: SQL error: near "on": syntax error

This will probably work:
sqlite3 places.sqlite "update or replace moz_places set url=replace(url,'quake3forum','quake3world') where url like '%quake3forum%'"

Actually, I'll probably use the ignore clause, then delete all the quake3forum URLs that are left behind.
But I have to close my browser to run it and I have a web based build running that takes 15 minutes in our old crappy system. Takes 34 seconds in my CI environment.
/me waits impatiently

Re: FF history & sqlite

Posted: Wed Oct 14, 2009 6:56 pm
by Fender
Awesome. All my q3f history has been replaced w/ q3w. :up:

Re: FF history & sqlite

Posted: Wed Oct 14, 2009 7:04 pm
by ^misantropia^
The link I posted doesn't mention it explicitly but the UPDATE OR REPLACE syntax is what you want.

Re: FF history & sqlite

Posted: Wed Oct 14, 2009 7:04 pm
by ^misantropia^
Heh. I start typing a post, bring some stuff to the kitchen, come back and hit submit and look what happens...