Class: CsvToSqlite::Database
- Inherits:
-
Object
- Object
- CsvToSqlite::Database
- Defined in:
- lib/database.rb
Instance Method Summary collapse
- #connect ⇒ Object
- #create ⇒ Object
-
#initialize(db_name: "data.sqlite3") ⇒ Database
constructor
A new instance of Database.
Constructor Details
#initialize(db_name: "data.sqlite3") ⇒ Database
Returns a new instance of Database.
6 7 8 9 10 |
# File 'lib/database.rb', line 6 def initialize db_name: "data.sqlite3" @db_name = db_name @target_dir = target_dir @database_path = "#{@target_dir}/#{@db_name}" end |
Instance Method Details
#connect ⇒ Object
21 22 23 24 |
# File 'lib/database.rb', line 21 def connect create SQLite3::Database.new @database_path end |
#create ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/database.rb', line 12 def create if File.exist? @database_path puts "Database found" else puts "Creating database" SQLite3::Database.new @database_path end end |