FF history & sqlite

Locked
Fender
Posts: 5876
Joined: Sun Jan 14, 2001 8:00 am

FF history & sqlite

Post 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?
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: FF history & sqlite

Post by ^misantropia^ »

Fender
Posts: 5876
Joined: Sun Jan 14, 2001 8:00 am

Re: FF history & sqlite

Post 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
Fender
Posts: 5876
Joined: Sun Jan 14, 2001 8:00 am

Re: FF history & sqlite

Post by Fender »

Awesome. All my q3f history has been replaced w/ q3w. :up:
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: FF history & sqlite

Post by ^misantropia^ »

The link I posted doesn't mention it explicitly but the UPDATE OR REPLACE syntax is what you want.
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: FF history & sqlite

Post by ^misantropia^ »

Heh. I start typing a post, bring some stuff to the kitchen, come back and hit submit and look what happens...
Locked