Connecting to an Oracle Database from Rails 4 - ruby

I have to do a query into an Oracle Database (11g) to extract an HTML file that is stored as a BLOB (yes BLOB, not CLOB) from my Rails 4 Application. So far while working with this database, since it is not well designed, I have been using a number of workarounds to get what I need to out of it. Unfortunately these are no longer working properly, and it would appear that the easiest way to get the HTML file, to later render in my Rails App, would just be to query the Oracle DB for it.
I have googled around on this issue, but everything I have found on the matter with any body to it is from a couple of years ago and no longer of much use to me. So I was wondering if anyone could tell me the best way to connect to an Oracle 11g Database for a single query from a Rails 4 Application / point me in the right direction to find documentation that will help me accomplish this.
Important to Reiterate: I am not trying to get this working with ActiveRecord as my primary DB for my app, instead I need to send one query and manipulate the response of that query.

The ruby-OCI8 gem can be configured to make a single SQL query to an Oracle Database, the docs have instructions on how to set up the necessary Oracle Instant Client.

Related

Is Oracle Database Supported in Joomla?

I would like to use Oracle database instead of MySQL in Joomla. Is this possible with Joomla, is there a workaround or a solution on how to implement Oracle database with Joomla? Any information will be greatly appreciated.
It is said that it can be done, but it is not a job for beginners and took those guys 3 working days to do it.
Here's why that combination doesn't work by default:
The database and table creation script does not work without modification.
The connection and the database class are written to connect to MySQL and not to Oracle (so they all use MySQL functions).
Some of the extensions use native MySQL functions directly, instead of connecting using the Joomla Database interface (class).
This is what they did to make it work:
We fix the SQL installation script to accommodate the Oracle database in case of a new installation. In case of an existing installation, we export all the database, as well as its data to a SQL file, and then we modify the SQL file (using find and replace) to make it work with an Oracle database.
We load the modified installation file or the modified exported SQL file into the Oracle database.
We then create a copy of the Joomla database class, and then we modify all the functions to work with Oracle instead of MySQL.
We ensure that the Oracle drivers are properly installed and loaded by the php.ini file.
We rename the original MySQL database (you will know in the next step why) to something like database_name_old.
We switch to the new database class and fully test the website to see if some extensions are not working. If an extension ceases to work then it is a sign that this extensions is calling the original MySQL database (which no longer exists because it was renamed) directly.
Hopefully, you aren't a beginner and those guidelines will help you do it. Otherwise, check how much it might cost by visiting the page.

Ruby: Mongoid Criteria Selector to SQL Query

As part of my bachelor's thesis I'm building a Microservice using Postgres which would in part replace an existing part of an application using MongoDB. Now to change as little as possible at the moment on the client side I was wondering if there was an easy way to translate a Mongoid::Criteria to an SQL query (assuming all fields are named the same, of course), without having to write a complete parser myself. Are there any gems out there that might support this?
Any input is highly appreciated.
Maybe you're looking for this : https://github.com/stripe/mosql.
I don't dig it but it seems to work for what you need :
"MoSQL imports the contents of your MongoDB database cluster into a PostgreSQL instance, using an oplog tailer to keep the SQL mirror live up-to-date. This lets you run production services against a MongoDB database, and then run offline analytics or reporting using the full power of SQL."

How do I do a SQLite to PostgreSQL migration?

I have a problem with migrating my SQLite3 database to PostgreSQL. How and what do I need to do?
I am searching the internet, but find only migrations from MySQL to PostgreSQL.
Can anyone help me?
I need to convert my SQLite database to PostgreSQL database for Heroku cloud hosting.
You don't want to try to do a binary conversion.
Instead, rely on exporting the data, then importing it, or use the query language of both and using selects and inserts.
I HIGHLY recommend you look at Sequel. It's a great ORM, that makes switching between DBMs very easy.
Read through the opening page and you'll get the idea. Follow that by reading through the cheat sheet and the rest of the documentation and you'll quickly see how easy and flexible it is to use.
Read about migrations in Sequel. They're akin to migrations in Rails, and make it very easy to develop a schema and maintain it across various systems.
Sequel makes it easy to open and read the SQLite3 table, and concurrently open a PostgreSQL database and write to it. For instance, this is a slightly modified version of the first two lines of the "cheat sheet":
SQLITE_DB = Sequel.sqlite('my_blog.db')
PGSQL_DB = Sequel.connect('postgres://user:password#localhost/my_db')
Base all your subsequent interactions with either database using SQLITE_DB and PGSQL_DB and you'll be on your way to porting the data.
The author of Sequel is very responsive and is a big fan of PostgreSQL, so the ORM has great integration with all its features.

MS Access to Oracle database

I am developing an ASP.net application with Access database. I need to convert this Access database to Oracle. How can I do that?
I saw two options
Migrating the access database to Oracle through MIGRATION WIZARD in SQL developer
In Oracle, just creating a new connection with existing MS Access database and then converting to oracle.
Kindly let me know the best solution for this
thanks in advance,
Arjun
The two choices you proffer could be rewritten like this:
Use an automated tool written by experts
Do it the hard way and figure it out for myself
This is a personal, even philosophical, choice. Do you need to get the task done quickly? Or do you want to learn something along the way?
TRY IT and then tell us.
My experience integrating all things oracle with all things microsoft has always been complicated, and a lot of manual intervention was required.
It also depends on the complexity of your existing access database, if it's only one table, then you can grab that table sql, correct it for nvarchar -> varchar2 fields and datapump the data into oracle.
If Access has 1000+ tables I would suggest getting a professional to do it. Any reasonable dba should handle it no problem.
Please check the solution at Insert into from ms access to oracle db
You can customize the code based on your requirement. You can bundle the whole code into one class and prepare it as exe application.

problems in inserting spanish words in oracle db

Is there a way to insert spanish words into the Oracle table - like 'España'.
When I try to insert it, it either takes the ASCII counterpart of it or replaces the 'ñ' with a '?'.
Has anyone done this before or knows a work around for it?
I found something while googling they told we have to mention spanish character set in init.ora file. I don't know how to do this and also setting nls_settings for client. I am using toad to connect to server which is located in UK.
Please help me in solving this problem.
First, you should check if the database was created with a character set that includes the Spanish characters that you want inserted. For versions of Oracle starting with 9i the wizards by default create the database using Unicode, so it shouldn't be a problem. But if the database wasn't created by you, this should be the first thing to check with the DBA that created it.
Which version of the Oracle server are you connecting to?
Which version of the Oracle client are you using? Which kind of Oracle client (OCI, JDBC, .NET)?
If the database was properly created it can be a problem related to the client platform.
And this is not simple to diagnose without information about the client OS, database client libraries that you are using and their configurations related to Natural Language Support.
So, I will point you to an Oracle FAQ related to this issue. It is a lot of material to read but it worths your time.
http://www.oracle.com/technetwork/database/globalization/nls-lang-099431.html

Resources