Crystal ODPI driver implements crystal-db API and is a wrapper around ODPI-C.
This is derived from crystal-oracle library.
Oracle Database Programming Interface for C (ODPI-C) is an open source library of C code that simplifies access to Oracle Database for applications written in C or C++.
-
Add the dependency to your
shard.yml
:dependencies: odpi: github: silkPK/crystal-odpi
-
Run
shards install
require "db"
require "odpi"
DB.open "odpi://user:password@host:port/SID" do |db|
db.exec "BEGIN EXECUTE IMMEDIATE 'drop table person'; EXCEPTION WHEN OTHERS THEN NULL; END;"
db.exec "create table person (name varchar(30), age int)"
db.exec "insert into person (name,age) values ('Paolino Paperino', 28)"
puts "max age:"
puts db.scalar "select max(age) from person"
puts "person:"
db.query "select name, age from person order by age desc" do |res|
puts "#{res.column_name(0)} (#{res.column_name(1)})"
res.each do
puts "#{res.read} (#{res.read})"
end
end
end
TODO: Write development instructions here
- Fork it (https://github.com/sourgrasses/crystal-odpi/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
- silkPK - creator and maintainer