Q:

URL encoding in SQLite

Is there a way to URL encode fields in SQLite directly in the query?
(somehow this question doesn't meet "quality standards" so I'll throw in an example query:)
select urlencode( field ) from table;

A:

Looking through the sqlite function list, I didn't find anything that would do the job. But you can construct such a function manually as follows:
select replace(replace(replace(replace(field,
    " ", "%20"),
    "/", "%2F"),
    "(", "%28"),
    ")", "%29")
from table;

This version escapes four of the more common problematic characters. It's a quick-and-dirty solution if your data set does not contain many unsafe characters.

