What I need to know when using shared database connection? - ruby

I'm developing FB app on Heroku, using Ruby, Sinatra and Mongo. I think that sharing database connection is a good idea but I don't know how it looks on production.

I'm not sure where you have looked or researched.
In addition to #Stennie's link above, check out the following links -
Look at the actual source code of the ruby driver on github. There's ample information there, including a section and an example of connection pooling.
Check out the overall ruby driver information
Some notes on pooling within the drivers.
See also this question answered by the original Ruby driver author on So.
If you're not using connection pooling, you may see the following messages in your logs.

Related

When did Heroku remove Postgres Connection Pooling from Hobby Tier?

I had a portfolio app that worked great, and I revisited it recently and it seems to have stalled out on all connections to the DB. Looking into it, it seems Heroku does not allow connection pooling for hobby tier DBs. I know this can't have always been the case since it worked when it was initially built, but the documentation doesn't indicate any specific time when this change was made. I'm hoping someone maybe knows when this feature removal was implemented. It seems like useful information that should be included in the documentation since knowing the specific date is helpful in fixing broken applications due to this change.

OnChange on a table is available in golang driver - rethinkDB?

I am working on RethinkDB and Golang and completely new to these two Technologies/Database.
Note
GOLang driver - I am using this driver for connecting rethinkDB.
Problem
There is no onChange on a table functionality in this driver.
Note - OnChange functionality is available in rethinkDB.
Any suggestion of golang driver which supports rethinkDB onChange.
Thanks in advance
Sorry for the delayed reply I dont check StackOverflow as often as I should.
GoRethink actually does offer support for Changefeeds. Unfortunately the documentation is currently a bit lacking and I hope to work soon, until then I recommend having a look at the tests. Hopefully that should give you an idea on how to use them.
https://github.com/dancannon/gorethink/blob/master/query_table_test.go#L215
If you have any further questions regarding change feeds or any other issues with the driver let me know.
That Go driver is provided by a third party and as you note they do not seem to have yet added support for changefeeds. It is hosted on GitHub, so you could file an enhancement request. There is recent activity in their repository, so there is hope that they will add it.

FND_VAULT package

I have to encrypt my SOAP message and send to destination and the respective decrypt algorithm should run there. I went through fnd_vault package of oracle but no where I got any useful Information so can anyone please provide me some material or way to deal with this package.
I know I am not expected to ask such question here, but I didn't find any post regarding fnd_vault package so have to post neither I got some satisfactory information after goggling on it. So thought that some discussion regarding this can be done here.
You would want to use TLS/SSL. Depending on what technology you use, you may need to select appropriate driver. I would start from here.
Example 1
You use web services that wraps database API. In this case use HTTPS connection and make sure that service side is configured to accept SSL connection (which means you need to install a trusted certificate on the web server).
Example 2
You use Java driver to directly connect to Oracle server. Use this manual to configure JDBC connection.

How does Node.JS and/or Meteor get a callback from the database when a 3rd party software update the database

I would like to use Meteor (Node.JS) to develop an application that will be used by 3,000+ concurrent users on a large size database.
I have looked at the nice examples and the idea to push changed data to the clients is very nice and very useful, but before I start the development I want to be sure how it works behind the scenes to be sure that when I have the application running with all these users it work fast with standard hardware.
I also require this to use Oracle as a database, but not sure that it is supported and if not, what are the requirements from an Oracle package to enable this facility.
I think that the server is having an active on going non-blocking query on the OPLOG table in mongodb and that is how we get the callback for all the changes in the database. Is that correct ? if so, is there a similar way to do it in Oracle ?
Thanks Roni.
I also require this to use Oracle as a database, but not sure that it is supported and if not, what are the requirements from an Oracle package to enable this facility.
Nope, meteor is currently mongo-only as they have implemented an in-browser library called minimongo. My guess is this project will never support oracle, but who knows. There is no mention of oracle support on the meteor project roadmap
Just happened to come across this question while searching at google.
However, if there are no native solutions. We can always figure out a way for a medium language to issue publishing.
Example Case:
Python will be used for synchronising data between Mongodb and Oracle (24/7 operation using cx_Oracle and MongoDB drivers from python)
Meteor Server will keep watch on what to publish
Meteor clients/browsers that subscribed to the channel that will be updated with oracle data.

Is there a way to connect to a H2 database from Ruby without JRuby?

I'm testing a web application with ruby 1.8.7 and WATiR and I'd like to connect to a H2 database as easily as possible, which I can only find info on JDBC access for. If there's a way to use JRuby to do this from Ruby that is okay, but I need to use Ruby primarily because my WATiR code is written in it and will hopefully remain so.
All possible solutions will be considered but I'm looking for some simplicity because my database knowledge is limited and I need to access the database (read from and write to) from Ruby/WATiR to test against what's displayed on the web front end.
EDIT: I removed some of my ignorance, now I know JDBC is a Java API for DB access, so I'm now looking for any way to connect to a H2 database so that my Ruby/WATiR scripts can access it.
Background:
I have some experience with DBI and Sequel gems, and I have Rails installed (so I can start to play with ActiveRecord, mainly), but willing to learn new things to solve this issue.
Let's assume I'm not a great Java coder. I've also never looked into using JRuby before, so I'm not entirely familiar with how it works.
Solution
I eventually got the two talking to each other, mainly thanks to Thomas Mueller's answer below. I installed the PostgreSQL ODBC driver, got Sequel working and connected using ODBC. Using Sequel's PG adapter to connect to the H2 PG server causes some Syntax errors that I'm still working on. I have not yet tried DBI to connect, but I will as it may give me greater control of the syntax should I need it. Many thanks also to Jeremy Evans for his help solving a conflict between activerecord-jdbc-adapter and Sequel (pesky pg.rb file in my ruby path), and for managing Sequel. This is not listed as an answer so that I can give credit to those that answered whilst giving feedback to people in the same situation as me.
I have installed pg (not ruby-pg), sequel, dbi, dbd-odbc (plus a manual file fix, you can ask me for details), hoe, and UNinstalled activerecord-jdbc-adapter.
H2 can act as a PostgreSQL server and supports the PostgreSQL ODBC driver.
So in theory you should be able to use ruby-pg. But I have never tried it myself, I guess the chances that it works are about 50%. So the answer is: maybe. But the preferred solution is to use JRuby.
If WATiR is written in Ruby... then WATiR should also work in JRuby?
there is no such thing named jdbc database, you can access any database using ruby so long as the database provides a ruby connector.
IMHO your two best options are either the DBI or Sequel gems.
The DBI gem can be used to connect to a db via ODBC. If H2 has an ability as Thomas indicates to support ODBC then you should be able to use DBI to connect to and query the db (which of course includes 'update' queries to setup given test data etc).
See the rubyforge DBI Page for more info. DBI has been around a while so it's fairly easy to find online tutorials for how to use it, etc. It is fairly low level, and you need to know SQL or your DB's language, in order to interact well with it.
Another option would be the SEQUEL gem, which has an option to connect via ODBC or JDBC (JDBC has a H2 sub-adaptor). This Gem is newer and offers some specific advantages over DBI. see this link to the Opening_Databases portion of the rdoc files for Sequel where it talks a little bit about using JDBC to connect to databases. I guess which is easier depends on how hard the ODBC is to setup for H2 vs how much Java you have to learn in order to get JDBC working for you. (I'd head for ODBC first if it was me, since I know very little Java)
Myself, I've been using DBI so far (to connect to MS SQL via ODBC), but I have to admit wondering if using the Sequel gem instead might be better. Sequel saves you from writing a lot of actual SQL type code or even having to understand SQL queries in depth, and lets you do everything ruby style using methods, symbols and some strings here and there. If you are doing a LOT of db interaction I can see where it is clearly superior especially in terms of being able to create a lot more pure OOP code. See this presentation by the Sequel author at a Ruby conference in 2009 for more details.
In my case DBI is 'good enough' for what I need since I am very comfortable with SQL, and don't really need to do much other than issue a few commands here and there to do db-level bit-twiddling to create proper test conditions. OTOH if I was having to do a lot of queries against the db as a test oracle and comparing that with data presented in the UI, I can see where using Sequel would make my life a lot easier.

Resources