Class: SequelRails::Storage::Sqlite

Inherits:
Abstract
  • Object
show all
Defined in:
lib/sequel_rails/storage/sqlite.rb

Instance Attribute Summary

Attributes inherited from Abstract

#config

Instance Method Summary collapse

Methods inherited from Abstract

#charset, #close_connections, #collation, #create, #database, #drop, #dump, #host, #initialize, #load, #owner, #password, #port, #schema_information_dump, #search_path, #username

Constructor Details

This class inherits a constructor from SequelRails::Storage::Abstract

Instance Method Details

#_createObject



4
5
6
7
# File 'lib/sequel_rails/storage/sqlite.rb', line 4

def _create
  return if in_memory?
  ::Sequel.connect(config.merge('database' => path))
end

#_dropObject



9
10
11
12
# File 'lib/sequel_rails/storage/sqlite.rb', line 9

def _drop
  return if in_memory?
  path.unlink if path.file?
end

#_dump(filename) ⇒ Object



14
15
16
17
18
19
# File 'lib/sequel_rails/storage/sqlite.rb', line 14

def _dump(filename)
  return if in_memory?
  escaped_path = SequelRails::Shellwords.shellescape(path.to_s)
  escaped_filename = SequelRails::Shellwords.shellescape(filename)
  exec "sqlite3 #{escaped_path} .schema > #{escaped_filename}"
end

#_load(filename) ⇒ Object



21
22
23
24
25
26
# File 'lib/sequel_rails/storage/sqlite.rb', line 21

def _load(filename)
  return if in_memory?
  escaped_path = SequelRails::Shellwords.shellescape(path.to_s)
  escaped_filename = SequelRails::Shellwords.shellescape(filename)
  exec "sqlite3 #{escaped_path} < #{escaped_filename}"
end