PG Gem Flashcards
Ruby PG Gem
create a new PG:Connection
object
PG.connect(dbname: “a_database”)
Ruby PG Gem
execute a SQL query and return a PG::Result
object
connection.exec(“SELECT * FROM…”)
Ruby PG Gem
return an array of arrays containing values for each row in result
result.values
Ruby PG Gem
return the names of columns as an array of strings
result.fields
Ruby PG Gem
return the number of rows in result
result.ntuples
Ruby PG Gem
yield a hash of column names and values to the block for each row in result
result.each(&block)
Ruby PG Gem
yield an array of values to the block for each row in result
result.each_row(&block)
Ruby PG Gem
return a hash of values for row at index
in result
result[index]
Ruby PG Gem
return an array of values for column
, one for each row in result
result.field_values(column)
Ruby PG Gem
return an array of values for column at index
, one for each row in result
result.column_values(index)
Ruby PG Gem
PG.connect(dbname: “a_database”)
create a new PG:Connection
object
Ruby PG Gem
connection.exec(“SELECT * FROM…”)
execute a SQL query and return a PG::Result
object
Ruby PG Gem
result.values
return an array of arrays containing values for each row in result
Ruby PG Gem
result.fields
return the names of columns as an array of strings
Ruby PG Gem
result.ntuples
return the number of rows in result