I'm using Ruby to create a test script connecting to oracle BD.
I have all the structure already set up, I can already connect and search the database.
Is there any way for me to display the SELECT content? Using only RUBY, I don't use Ruby on Rails.
Related
I am Looking to import(Rather run the schema.sql and seed.sql) in to the SQL server database using sequel gem. Is it possible with the gem? I did some very basic things like creating a database, running few queries etc. But Can not find any example for importing SQL file.
Thanks
j
Sequel doesn't support taking a string/file of multiple SQL statements and running it. You need to provide each SQL statement as a separate query string. Some adapters may allow the submission of multiple SQL statements in a single query string, but it is undefined behavior that depends on which driver is being used.
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.
I have the Remedy odbc driver installed on my machine. I am able to pull down data from Remedy via excel just fine specifying this driver in my connection.
Is there any way I could use this driver from within Ruby / Ruby on rails to connect to and read from the DB?
Many thanks!
I have not found a way to use the Remedy ODBC driver from Ruby. Also, I am suspecting that using the driver which seems to be quite antiquated and is already throwing some arcane errors when used from Excel might not be simple to use.
I was able to connect through R via RODBC and thus an R script that would pull the data for you and write to CSV might be a solution.
What I am actually using - which to my mind is the simplest way of achieving this - is talking directly to the Remedy SQL backend. All that you will have to do is parse the data upon pulling it from DB which is very easy to set up (priorities, service types, statuses are stored as integers and not actual names and timestamps are in epoch format).
How to fetch DB results from TOAD for DB2 using Ruby/capybara
Are you asking about TOAD, the DB client app? If so, Capybara is not the tool you should use as it only works for web apps (browser or headless browser tests). If you want to check the contents of a DB2 database using ruby then you could connect to it with ActiveRecord and run queries using that. On the other hand if you want to automate TOAD's user interface using ruby/capybara then you're out of luck - that's not possible.
I'm using Ruby 1.9.3, MS Sql Server and Windows 7 Ultimate
I'd like to know how to check if a certain record is already existing in the database so that I would avoid duplicate records. In rails it would have been easy to just invoke Object.exists? but I'm using Ruby only.
Thanks
Check the source code for exists? in activerecord
It basically checks if there primary key with the id exists already using sql query.
you can use these to write your own helper method.
or else u can also use activerecord gem in ruby too.