Method: FatTable::Table.from_sql
- Defined in:
- lib/fat_table/table.rb
.from_sql(query, **types) ⇒ Object
Construct a Table by running a SQL +query+ against the database set up with FatTable.connect, with the rows of the query result as rows.
244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/fat_table/table.rb', line 244 def self.from_sql(query, **types) msg = 'FatTable.db must be set with FatTable.connect' raise UserError, msg if FatTable.db.nil? result = Table.new rows = FatTable.db[query] rows.each do |h| result << h end result end |