KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Right now I am in the middle of migrating from SQLite to Postgresql and I came across this problem. The following prepared statement works with SQLite: id = 5 st = ActiveRecord::Base.connection.raw_connection.prepare("DELETE FROM my_table WHERE id = ?") st.execute(id) st.close Unfortunately it is not working with Postgresql - it throws an exception at line 2. I was looking for solutions and came across this: id = 5 require 'pg' conn = PG::Connection.open(:dbname => 'my_db_development') conn.prepare('statement1', 'DELETE FROM my_table WHERE id = $1') conn.exec_prepared('statement1', [ id ]) This one fails at line 3. When I print the exception like this rescue => ex ex contains this {"connection":{}} Executing the SQL in a command line works. Any idea what I am doing wrong? Thanks in advance!
Tags (comma-separated)
Save Edits
Cancel