d1
D1
Cloudflare API for D1 databases written in Crystal.
Installation
-
Add the dependency to your
shard.yml:dependencies: d1: github: joseafga/d1 -
Run
shards install
Usage
require "d1"
Configure credentials
D1.configure do |config|
config.account_id = "023e105f4ecef8ad9ca31a8372d0c353"
config.api_token = "Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"
end
Run SQL
D1.open("database-uuid") do |db|
db.exec "CREATE TABLE Users (id INTEGER PRIMARY KEY, name TEXT NOT NULL, age INTEGER);"
db.exec "INSERT INTO Users (name, age) VALUES ('Billy', 30)"
result = db.query "SELECT * FROM Users WHERE age = ?", 30
puts result.first["name"].as_s # => Billy
end
Contributing
- Fork it (https://github.com/joseafga/d1/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
- José Almeida - creator and maintainer
Repository
d1
Owner
Statistic
- 0
- 0
- 0
- 0
- 0
- about 5 hours ago
- November 6, 2025
License
MIT License
Links
Synced at
Fri, 21 Nov 2025 09:35:16 GMT
Languages