In the introductory tutorials, it talks about MySQL, Postgre and Sqlite3. Is anything else supported out-of-the-box? Are there any plugins to support other databases?
I'm mainly interested in NoSQL - Cassandra, CouchDB, etc.
Thanks
Activerecord (Rails' default ORM) supports MySQL, Postgres, and sqlite3. If you want to use a different ORM, you have many more choices.
Some links to get you started:
DataMapper, a popular alternative ORM
Sequel, another alternative ORM
Rails wiki article on using CouchDB
Mongoid, for MongoDB
MongoMapper, an alternative for MongoDB
I don't have enough experience with Cassandra to mention anything for it. This frontier has not been fully explored.
The game is likely to change some when Rails 3 comes out soon. Expect a lot of choices in this area to sprout up.
Take a look here and here and this last one(for couch). Also - if you're using JRuby - you can use any database that has a JDBC driver - which is just about every database around there.
Ruby on Rails 3 ( still in beta ) is ORM agnostic. So You can change your ORM. Or even you can not use ORM.
So the limitation is in Ruby, not in Ruby on Rails. in futur.
The ActiveModel gem help you with several librarie for compatibility. So you can even made you backend in File or with your own database.
Here we can see on the source code the list of available DBs: https://github.com/rails/rails/tree/b002141b1ba2eef5d192ec31bec5340f7ecca5e9/activerecord/lib/active_record/connection_adapters which as shqdowbq mentions is PostgreSQL, MySQL and SQLite.
https://www.ruby-toolbox.com/categories/Active_Record_DB_Adapters contains a list of third party adapters for other databases, listed options include:
https://github.com/rails-sqlserver/activerecord-sqlserver-adapter for Microsoft SQL Server
https://github.com/rsim/oracle-enhanced for Oracle
Related question: List of supported databases?
Related
QUESTION: Is there a go-to GUI or visual interface that can be used with the PostgreSQL database in Ruby on Rails?
1. SUMMARIZING THE PROBLEM
It would be easier for me to work with the database in Rails if I had a good visual interface. I think that RailsAdmin seems like a good option, but I am wondering what is the most popular/widely-used interace.
2. WHAT I'VE TRIED
I have seen that people can integrate MySQL and the MySQL Workbench with Ruby on Rails. I am curious if there is an easy-to-use gem that provides a visual interface for the PostgreSQL database in Rails. Below are a couple of questions with some decent answers. However, I am curious about what would be the standard or go-to interface.
Visual Interface to database mysql with Ruby on Rails
Is there a "phpmyadmin" for Ruby on Rails?
Thank you in advance for reading my question and I look forward to reviewing the answers!
I heard Postico https://eggerapps.at/postico/ is nice.
You can write and test your sql there and see the results
Table Plus is great. Far better than Sequel Pro IMHO.
If you're looking for a Rails Admin alternative, I would check out Active Admin
Is there a list of supported databases for RoR? I'm looking for MongoDB support but couldn't find anything official.
I'm a python/djangoist and have no clue for what keyword I should search in the RoR world. :(
All official I could find was that small list saying:
Migrations are currently supported in MySQL, PostgreSQL, SQLite, SQL Server, Sybase, and Oracle (all supported databases except DB2).
Are these all? Or is there maybe an app/plugin/whatever-its-called for RoR I could use?
First Question:
You are looking for supported databases officially covered by activerecord, the ORM default implementation in ruby on rails.
These are the supported connection adapters out of the box without gem enhancements.
Only these databases:
MySQL, PostgreSQL, SQLite
Source Code:
https://github.com/rails/rails/tree/master/activerecord/lib/active_record/connection_adapters
Second Question:
Mongo-Mapper is the gem that should be used to integrate MongoDB into Ruby On Rails 3.
Ruby Gem:
http://rubygems.org/gems/mongo_mapper
Instructions:
http://www.mongodb.org/display/DOCS/Rails+3+-+Getting+Started
As a start you may want to check out the Ruby Toolbox in the category of MongoDB clients.
Can I use MongoDB and a PostgreSQL in one rails app? Specifically I will eventually want to use something like MongoHQ. So far I have failed to get this working in experimentation. And it concerns me that the MongoDB documentation specifically says I have to disable ActiveRecord. Any advice would be appreciated.
You don't need to disable ActiveRecord to use MongoDB. Check out Mongoid and just add the gem plus any models along side any of your existing ActiveRecord models. You should note that MongoHQ is just a hosting service for MongoDB and can be used alongside any Object Document Mapper (ODM).
For further details check http://mongoid.org/en/mongoid/docs/installation.html. Just skip the optional 'Getting Rid of Active Record' step.
On a recent client site I worked with a production system that merged MySQL and MongoDB data with a single Java app. To be honest, it was a nightmare. To join data between the two databases required complex Java data structures and lots of code, which is actually databases do best.
One use-case for a two database system is to have the pure transactional data in the SQL database, and the aggregate the data into MongoDB for reporting etc. In fact this had been the original plan at the client, but along the way the databases became interrelated for transactional data.
The system has become so difficult to maintain that is is planned to be scrapped and replaced with a MongoDB-only solution (using Meteor.js).
Postgres has excellent support for JSON documents via it's jsonb datatype, and it is fully supported under Rails 4.2, out of the box. I have also worked with this and I find it a breeze, and I would recommend this approach.
This allows an easy mix of SQL and NoSQL transactions, eg
select id, blast_results::json#>'{"BlastOutput2","report","results","search","hits"}'
from blast_caches
where id in
(select primer_left_blast_cache_id
from primer3_output_pairs where id in (185423,185422,185421,185420,185419) )
It doesn't offer the full MongoDB data manipulation features, but probably is enough for most needs.
Some useful links here:
http://nandovieira.com/using-postgresql-and-jsonb-with-ruby-on-rails
https://dockyard.com/blog/2014/05/27/avoid-rails-when-generating-json-responses-with-postgresql
There are also reports that it can outperform MongoDB on json:
http://www.slideshare.net/EnterpriseDB/the-nosql-way-in-postgres
Another option would be to move your Rails app entirely to MongoDB, and Rails has very good support for MongoDB.
I would not recommend running two databases, based on personal observations on how it can go bad.
I understood that we interact with DB using Active Record.
My question is, if Active Record in rails is a driver?
No it isnt. ActiveRecord is simply an library that adds ORM functionality to your data. It provides you with objects that encapsulate a row in the database table and adds business logic to it. AR also provides you some other excellent ways to smartly handle your data and it relationship, mostly keeping you agnostic from the nitty-gritty details of the different databases out there.
The drivers that are used for the db connectivity are not provided by AR and they are specific to the database that you use. There are some libraries that are specifically included for connecting to different databases like the mysql2 driver for connecting to MySQL, similarly for the other databases.
In short, ActiveRecord isn't only driver. Drivers are gems mysql, pg, sqlite... ActiveRecors is thing like ORM for abstract database driver. wiki
I'm currently using SQLite3 with a simple post and image sharing app, similar to the Rails 3 Hartl tutorial (in terms of db structure). But I'd like to move to Mongo for future scalability/learning.
I'm also hosted on Heroku, and am using a 15 GB shared db. I attempted to install MongoHQ and MongoMapper (as per Heroku's instructions) for the transition and this part according to Heroku's support is set up correctly. However, when I turn off the shared db, the app stops working, rather than running off of Mongo.
I'm not sure what do do next, do I have to rewrite my code in mongo or does mongo mapper solve all that? Do I lose my data if I change, if so, how do I copy?
Could any of you please point me to some resources or help me out? Thank you very much!!
MongoDB is not a drop in replacement for a SQL database. There are a couple of things you need to adapt:
The models' code are to be updated to use MongoDB. I can suggest using Mongoid, an ODM, as it will ease your learning path. Mongoid implements Active Record.
The current data saved in your SQL database needs to be migrated - and this is not automatic – to MongoDB schemas. MongoDB do not support migrations as you are used to in SQL world. You will need to write your own scripts for that.
I suggest you write a simple app from scratch using your MongoDB ODM of choice – MongoMapper or Mongoid – so that you get familiar with the basis of MongoDB before attempting to make a migration.