Reputation: 3013
I've some huge text files to process and make sense out of the data. Part of the task is to save this data into a database. I want to use Ruby, with postgres or mysql, postgres being the first choice. What libraries should I include? There is no model, its going to be plain SQL statements. How to do this without rails?
Upvotes: 6
Views: 13501
Reputation: 4566
for mysql, check out the mysql2 gem
#>> gem install mysql2
require 'mysql2'
client = Mysql2::Client.new(:host => "localhost", :username => "root")
Upvotes: 0
Reputation: 4294
For PostgreSQL, you want ruby-pg. It supplies your basic database connection with the ability to query it. The documentation is sparse, but there are plenty of code samples in the source tree. Here's a fairly straightforward one:
Edit: The MySQL site lists a few options for connecting to MySQL.
http://dev.mysql.com/downloads/ruby.html
Upvotes: 4
Reputation: 2381
Sequel - sequel.rubyforge.org - is great as well. Using the core library (not the Sequel::Model ORM) you can write SQL like queries/statements using Ruby syntax.
Upvotes: 4
Reputation: 132227
You're after ActiveRecord, which supplies the database connectivity. A quick google search suggested this might be a good place to start.
Upvotes: 0