github.com/plambert/sqlite3_uri.cr
main / published Jul 8, 2025 / repository
Add support for reading/writing URIs as a String to sqlite3 databases
sqlite3_uri
Automatically convert URI instances to a String when writing to a sqlite3 database,
and expect a String to convert back to a URI instance when reading from a
ResultSet.
Installation
-
Add the dependency to your
shard.yml:dependencies: sqlite3_uri: github: plambert/sqlite3_uri.cr -
Run
shards install
Both db and sqlite3 will be brought in as dependencies by this shard; you don't need
to specify them separately in your shard.yml.
Usage
require "sqlite3_uri"
DB.open "sqlite3:%3Amemory%3A" do |db|
db.exec "CREATE TABLE urls (id INTEGER PRIMARY KEY, url TEXT NOT NULL)"
ARGV.each do |url|
db.exec "INSERT INTO urls (url) VALUES (?)", URI.parse url
end
urls = db.query_all "SELECT url FROM urls", as: URI
puts urls.inspect
end
Contributing
- Fork it (https://github.com/plambert/sqlite3_uri.cr/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Paul M. Lambert - creator and maintainer
API
This version publishes no documented types.