Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActiveRecord and NoSQL

I've been working with Rails for a few years and am very used to ActiveRecord, but have recently landed a task that would benefit from (some) NoSQL data storage.

A small amount of data would be best placed in a NoSQL system, but the bulk would still be in an RDBMS. Every NoSQL wrapper/gem I've looked at, though, seems to necessitate the removal of ActiveRecord from the application.

Is there a suggested method of combining the two technologies?

like image 746
user1381745 Avatar asked Dec 17 '14 15:12

user1381745


People also ask

What is ActiveRecord?

Active Record allows you to validate the state of a model before it gets written into the database. There are several methods that you can use to check your models and validate that an attribute value is not empty, is unique and not already in the database, follows a specific format, and many more.

Can Redis be used as a NoSQL database?

Redis is an open source, in-memory key-value data structure store, which can be used as a database, cache, or message broker. It's a NoSQL database.

Is ActiveRecord an ORM?

ActiveRecord is an ORM. It's a layer of Ruby code that runs between your database and your logic code.

How do I connect to NoSQL with Python?

In order to connect to MongoDB, python uses a library known as pymongo. You can add this library to your python environment, using the below command from the Anaconda environment. This library enables python to connect to MOngoDB using a db client. Once connected we select the db name to be used for various operations.


1 Answers

Not sure what NoSQL service you are looking into, but we have used MongoDB in concert with Postgres for a while now. Helpful hint, they say you need to get rid of ActiveRecord, but in reality, you don't. Most just say that because you end up not setting up your database.yml and/or running rake commands to setup AR DB.

Remember also that Postgres has HStore and JSON datatypes which give similar functionality as NoSQL datastores. Also, if the data you are looking to store outside of your AR DB is not very complex, I would highly recommend looking into Redis.

like image 141
tagCincy Avatar answered Oct 13 '22 10:10

tagCincy