Is it possible to run Mongo client shell query/commands from Ruby? - ruby

Could I use the Mongo client shell queries/commands from inside Ruby?
I know there is the Ruby driver DSL, but I was thinking about something similar to running a SQL query from within PHP.
Just for the sake of knowing.

You can always work directly with the MongoDB Ruby driver. Read this tutorial for more information.

Related

How to execute query over Amazon Athena with Ruby?

how to connect Amazon Athena with Ruby and execute query over Amazon Athena and get result.
we not able to find any gem or example with help us to connect Amazon Athena in ruby.
Please provide any reference using which we can use to build connection with Amazon Athena and build a custom query executor in Ruby.
just to clarify my application on production so changing SDK from Ruby to JRuby is not a suitable option for me.
Per May 19th 2017, Amazon Athena supports query execution via SDK and CLI.
Ruby API client for Athena documentation # docs.aws.amazon.com
Source code of aws-sdk-athena # github.com/aws/aws-sdk-ruby
I found that the official Amazon SDK for athena was a bit complicated, so I made a new gem called Athens that wraps the SDK in a nicer interface:
conn = Athens::Connection.new(database: 'sample')
query = conn.execute("SELECT * FROM mytable")
If using JRuby is not acceptable, there is another option that could work - but be warned that it's not 100% Ruby!
You could set up a Java Lambda function that encapsulates the query logic, taking in search parameters and then connecting directly to Athena using the JDBC driver.
Then call the Lambda function from Ruby - either via HTTP or through the Ruby client.
Using Lambda function is good alternative but if some one not like to pay additional service amount then batter to implment small application with jetty using rest service in JAVA with sql query as parameter and response text as output(your prefer format) will give you workaround to move on.
JRuby is required. Athena offers only JDBC driver. It works only in JRE.

Does ruby has a feature like socksProxy in java?

When I write a program in java, I use -DsocksProxyHost, -DsockProxyPort options to proxy all my network request to the specified address.
Does ruby has a feature like that?
I know there are Proxy class in ruby. However, I do not think I can utilize it when I want to connect to oracle database.
You can do this with JRuby using the -J flag which passes options to the JVM:
jruby -J-DsocksProxyHost=domain program.rb
MRI/Rubinius don't have a similar flag, but you can use a gem like proxifier or socksify to do the dirty work for you.

Embedded MongoDB instance?

I've been using MongoDB for a little tool that I'm building, but I have two problems that I don't know if I can "solve". Those problems are mainly related with having to start a MongoDB server (mongod).
The first is that I have to run two commands every time that I want to use it (mongod and my app's command) and the other is testing. For now, I'm using different collections for "production" and "test", but it would be better to have just an embedded / self-contained instance that I can start and drop whenever I want.
Is that possible? Or should I just use something else, like SQLite for that?
Thanks!
Another similar project is https://github.com/Softmotions/ejdb.
The query syntax is similar to mongodb.
We use this at work - https://github.com/flapdoodle-oss/embedmongo.flapdoodle.de - to fire up embedded Mongo for integration tests. Has worked really well.
I haven't tried it, but I just found this Ruby implementation of an embedded MongoDB: https://github.com/gdb/embedded-mongo

Mongo ruby driver: Running/getting mongostats/query Graphs

I am using mongo-ruby-driver, I want to get stats/query graphs to show for Mongo. But don't how can I get Mongostats/Graphs via mongo-ruby-driver.
Any help is highly appreciated.
Rather than righting your own, you can just set up MMS and use that instead.
But, if you do want to pull the data directly, you can do that too - anything that can be run from the shell can be run from the driver. So, for example, to run the stats() command, which translates on the command line to:
db.runCommand({dbstats : 1})
And so, just follow the guidelines at the top of the ruby driver FAQ - the first one includes how to run any of the commands via the driver.

Can you connect to a MS Access database from Ruby running on a Mac?

I'm pretty sure the answer is "no" but I thought I'd check.
Background:
I have some legacy data in Access, need to get it into MySQL, which will be the DB server for a Ruby application that uses this legacy data.
Data has to be processed and transformed. Access and MySQL schemas are totally different. I want to write a rake task in Ruby to do the migration.
I'm planning to use the techniques outlined in this blog post: Using Ruby and ADO to Work with Access Databases. But I could use a different technique if it solves the problem.
I'm comfortable working on Unix-like computers, such as Macs. I avoid working in Windows because it fills me with deep existential horror.
Is there a practical way that I can write and run my rake task on my Mac and have it reach across the network to the grunting Mordor that is my Windows box and delicately pluck the data out like a team of commandos rescuing a group of hostages? Or do I have to just write this and run it on Windows?
Why don't you export it from MS-Access into Excel or CSV files and then import it into a separate MySQL database? Then you can rake the new one to your heart's content.
Mac ODBC drivers that open Access databases are available for about $30.00
http://www.actualtechnologies.com/product_access.php is one. I just run access inside vmware on my mac and expore to csv/excel as CodeSlave mentioned.
ODBC might be handy in case you want to use the access database to do a more direct transfer.
Hope that helps.
I had a similar issue where I wanted to use ruby with sql server. The best solution I found was using jruby with the java jdbc drivers. I'm guessing this will work with access as well, but I don't know anything about access

Resources