You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using this gem in production alongside with Sinatra, ActiveRecord and Puma. Puma is running with 2 workers.
My code for database queries is identical to the following snippet:
database_connections=YAML.load_file('./databases_list.yml')database_connections.eachdo |connection_info|
connection=ActiveRecord::Base.establish_connection(connection_info)connection.execute('SELECT * FROM ...')# Other SQL queries hereconnection.disconnect!end
I have a list of identical databases (running on distinct servers) that I have to connect to and collect some data. But I'm suspecting I'm doing something terribly wrong, as when this code gets executed, the ruby interpreter raises a Dropped DB Cursor exception.
Do you have any idea of what can be possibly causing this error?
The text was updated successfully, but these errors were encountered:
It would be easier if you were using ActiveRecord OR fb, rather than something in between. If you're not making use of ActiveRecord, either connect directly using fb's API or grab raw_connection from ActiveRecord::Base.connection.
fb's connection's execute method either returns a cursor or takes a block with a cursor as a parameter. Basically, you need to program against the API as it exists, and not how you're guessing it is.
If you just want results, raw_connection.query will give you them. Given that execute returns a cursor, you should close that cursor when you're done iterating it.
I'm using this gem in production alongside with Sinatra, ActiveRecord and Puma. Puma is running with 2 workers.
My code for database queries is identical to the following snippet:
I have a list of identical databases (running on distinct servers) that I have to connect to and collect some data. But I'm suspecting I'm doing something terribly wrong, as when this code gets executed, the ruby interpreter raises a
Dropped DB Cursor
exception.Do you have any idea of what can be possibly causing this error?
The text was updated successfully, but these errors were encountered: