Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4612

ruby raised another command is already in progress

$
0
0

I would like to enter a large amount of data in my file.To do this, I am thinking of using postgresql's asynchronous processing to do the query.The code is as follows.

raw_conn = ActiveRecord::Base.connection.raw_connectionraw_conn.send_query("SELECT id FROM users")raw_conn.set_single_row_modebegin  raw_conn.get_result.stream_each do |f|    # writing process to file  endendraw_conn.send_query("SELECT id FROM logins")raw_conn.set_single_row_modebegin  raw_conn.get_result.stream_each do |f|    # writing process to file  endend

When the second send_query is executed, the following error occurs.

 another command is already in progress

I had a feeling that the connection pool was the cause, but the documentation did not mention it.Is there any way to run send_query more than once and get results?


Viewing all articles
Browse latest Browse all 4612

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>