PostgreSql:
def select(sql, name = nil)
res = execute(sql, name)
results = res.result
rows = []
if results.length > 0
init = Time.now
results.each do |row|
fields = res.fields
hashed_row = {}
row.each_index do |cel_index|
column = row[cel_index]
case res.type(cel_index)
when BYTEA_COLUMN_TYPE_OID
column = unescape_bytea(column)
when TIMESTAMPTZOID, TIMESTAMPOID
column = cast_to_time(column)
when NUMERIC_COLUMN_TYPE_OID
column = column.to_d if column.respond_to?(:to_d)
end
hashed_row[fields[cel_index]] = column
end
rows