I need to access data in an MS SQL database from a rails app.
The MS SQL database is maintained by our contractors, we just need to access data from it.
Is there a way in rails that I can access an outside db (not the main rails db)?
I can write my own SQL queries, I just need to open a connection to that outside db.
I'm on Rails 3.2.1
Thanks
Check out Connection Ninja , it's pretty straight forward and easy to use.
Related
I need to Query an online SQL database from an iPhone app. I have been researching and have not been able to find a way to use SQL to directly query my non-local online database from my iOS app.
Is there any way to do this?
Or do you need a web service, restful api using json?
If so, can you lead me in the right direction on creating a web service (or resources that handle that for you)?
I have be trying the same thing and I endet up doing it via a MySQL DataBase on a 1&1 web domain, to Query the DataBase I made a PHP program, using (like you said) JSON to be read by the app. I dont know if that is what you meant if not maybe specifie pls. XD
I have been using Heroku-postgres as my database for my rails 4 app deployed to Heroku.
I connect to the DB locally using pgAdmin3, and haven't had any issues.
Now, I want to switch my database to a amazon-redshift instance which has been spun up for me. All I have is a username, password, and the database host name. Where do I store this information within my Rails 4 app so that my app will use this DB instead of the current postgres DB?
I provided a similar answer here, but I would recommend using this adapter to connect:
https://github.com/fiksu/activerecord-redshift-adapter
This certainly works well for any ActiveRecord query you need to do, I'm using insert statements to update redshift tables rather than ActiveRecord create. Working on a full redshift adapter, hopefully to be released in the next few weeks.
Here's the answer I've given in the past with code examples about halfway down:
How can I build a front end for querying a Redshift database (hopefully with Rails)
Heroku will need to support Redshift as a database option for you, otherwise you'll need to spin up your own stack.
It might be worthwhile checking out AWS EBS service to do this.
While using the Neography gem to implement a Neo4j database on a Rails app, it so appears that the database is local to that particular Rails app's embedded Neo4j server. I wish to share a common Neo4j DB between two Rails apps, just the way you could do with a MySQL database through entries into database.yml. Is this impossible while using Neography? If so, what could be my possible alternatives which don't involve JRuby(i.e. using neo4j.rb).
Neography is a wrapper to query a neo4j server through the REST protocol. In that case, you should be able to query from anywhere you want, once you have started the server, even with a simple curl command.
You want especially to uncomment this line in conf/neo4j-server.properties if your apps are on 2 different servers :
org.neo4j.server.webserver.address=0.0.0.0
Make sure however to protect your database, you can read here how to : http://docs.neo4j.org/chunked/stable/security-server.html
I have a client which want to have data from a form to an access database. I seen some odbc connector for rails but it's only old projects.
I can export/inport data in CSV but I want the simpler solution.
Do you know if there is a solution to connect Rails with Access?
Thanks!
If his access database doesnt already exist then a good solution would be to create a rails application with a MySQL database then use microsoft access as a front end to the mysql db (OBDC). Ref Access as front end to MySQL
So he can see all data from the mysql db through access and easily import the entire db to his local machine if he wanted to but it wouldn't be required.
I want to write a few unit tests that do not make any changes to a database.
I have a Rails 2.3.11 application. This app has a SQLite database as its primary database. In many ways, this is a run-of-the-mill Rails app.
What makes this app unique is that it also establishes a connection to a SQL Server database. I have some models which are abstract classes and they use the SQL Server database. I have before_save and before_destroy callbacks to prevent any changes being made to the SQL Server database. Also, the user credentials to connect to SQL Server are supposed to be read-only.
I would like to write unit tests that make assertions on the data that is already present in the SQL Server database. But I don't want to setup or teardown the SQL Server database.
I am afraid to just see what happens. I would like to have a setting in the unit test that will prevent Rails from trying to setup or teardown the SQL Server database. Is this possible? How do I do it?
Thank you!
The setup/tear down only affects the application database (SQLite, sounds like), not additional, external database connections.
Also, you should keep your test environment completely separate from your production environment. So, if you're using a test SQLServer DB as well (and you should be, with test data in it - not the production one) then you should be fine even if the worst happens.