I am trying to use Lua to retrieve some currency conversion rates from a postgres database. It works but the numeric field value is only returning the first three decimal places although if I list the data in postgres it has four decimal places. I may be doing something daft as I am quite new to Lua, sample code is below. Any ideas appreciated

regards, John


local dbh = freeswitch.Dbh("odbc://fs_odbc:fs_user:password")
if dbh:connected() == false then
 freeswitch.consoleLog("notice", "dp.lua cannot connect to database" .. dsn .. "\n")
 return
end
assert(dbh:connected())

e_rate = 1.123456789
-- just a test to see decimal places
freeswitch.consoleLog("info",string.format(" e_rate = %f", e_rate))

local function eur2usd()
   local sql = "select eur2usd from currency order by id desc limit 1"
   dbh:query(sql, function(row)
       e_rate = row.eur2usd
       end)
end

local function eur2gbp()
   local sql = "select eur2gbp from currency order by id desc limit 1"
   dbh:query(sql, function(row)
       e_rate = row.eur2gbp
       end)
end

eur2usd()
freeswitch.consoleLog("info",string.format(" euro2usd = %f", e_rate))
eur2gbp()
freeswitch.consoleLog("info",string.format(" euro2gbp = %f", e_rate))