I’m not sure where I’m supposed to be asking this. If this is the wrong place, can you please redirect me to the correct spot and I can re-post there.
I only discovered rom rb a couple of months ago. I’m also a bit of a newbie when it comes to ruby. I’m trying to connect to the database using an options hash rather than a connection string, like so:
@rom = ROM.container(:sql, adapter: 'mysql2', user: 'someuser', password: 'somepassword', database: 'somedb', host: '127.0.0.1', port: 6603) do |config| ... end
I’m not using a framework or anything. I’m just doing everything in a standalone directory, trying to learn how this all works. I’ve used the sequel gem before and was able to connect using an options hash and assumed that we could do the same thing via rom but I get the following error:
URI::InvalidURIError: bad URI(is not URI?): {:adapter=>"mysql2", :user=>"someuser", :password=>"somepassword", :database=>"somedb", :host=>"127.0.0.1", :port=>6603}
In trying to learn how the connection is supposed to work, I traced it down to the file rom-sql-1.2.2/lib/rom/sql/gateway.rb
def connect(uri, *args) case uri when ::Sequel::Database uri else ::Sequel.connect(uri.to_s, *args) end end
Is the ::Sequel.connect
line supposed to convert the uri.to_s? If I remove the to_s and let it go into into the sequel connect as a hash, things just seem to work.
Am I misusing rom rb if I want to be able to connect via an options hash?
The documentation only provides using a connection string as an example so I’m wondering whether I’m doing something incorrectly.
Any help would be much appreciated.