0

Rails Code:

sql = File.read("#{Rails.root}/scripts/refresh.sql")

db_con = ActiveRecord::Base.connection
db_con.execute(sql)

file refresh.sql:

select 1;

If I create or modify file refresh.sql in pgAdmin (Ubuntu or Windows) I will get the following error:

PG::SyntaxError: ERROR:  syntax error at or near "select" 
LINE 1: select 1;

However, if I copy and paste the sql text into a text editor (sublime or gedit) and overwrite file refresh.sql the code runs

WiredIn
  • 4,157
  • 4
  • 27
  • 23

1 Answers1

0

pgAdmin III main window File => Options => Query file

Uncheck option "Read and write Unicode UTF-8 files"

enter image description here

WiredIn
  • 4,157
  • 4
  • 27
  • 23