sqlite3_uri.cr

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

  1. Add the dependency to your shard.yml:

    dependencies:
      sqlite3_uri:
        github: plambert/sqlite3_uri.cr
    
  2. 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

  1. Fork it (https://github.com/plambert/sqlite3_uri.cr/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

Repository

sqlite3_uri.cr

Owner
Statistic
  • 0
  • 0
  • 0
  • 1
  • 1
  • about 20 hours ago
  • July 8, 2025
License

MIT License

Links
Synced at

Tue, 08 Jul 2025 21:52:38 GMT

Languages