Class: Sqlite3
- Inherits:
-
Object
- Object
- Sqlite3
- Defined in:
- lib/adapters/sqlite3.rb
Instance Method Summary collapse
- #fields(table) ⇒ Object
-
#initialize(database, show_sql = false) ⇒ Sqlite3
constructor
A new instance of Sqlite3.
- #query(sql) ⇒ Object
Constructor Details
#initialize(database, show_sql = false) ⇒ Sqlite3
Returns a new instance of Sqlite3.
5 6 7 8 9 |
# File 'lib/adapters/sqlite3.rb', line 5 def initialize(database,show_sql=false) @client = SQLite3::Database.new(database) @client.results_as_hash=true @show_sql = show_sql end |
Instance Method Details
#fields(table) ⇒ Object
16 17 18 |
# File 'lib/adapters/sqlite3.rb', line 16 def fields(table) query('select * from ' + table.to_s).fields end |
#query(sql) ⇒ Object
11 12 13 14 |
# File 'lib/adapters/sqlite3.rb', line 11 def query(sql) puts sql if @show_sql @client.execute(sql) end |