Sha256: 1defd7c2c12990b3d9d129bb11e7125c6ff626efdbb9d5663d4166895247d213
Contents?: true
Size: 1.15 KB
Versions: 3
Compression:
Stored size: 1.15 KB
Contents
module CsvFastImporter module Database # Inherit from this class to create new custom database implementation # Do not forget to call .identifier_quote_character class Queryable def initialize(connection) @connection = connection end # Character used around identifiers (table or column name) to handle special characters def self.identifier_quote_character(character) define_method "identify" do |identifier| character + identifier + character end end def identify(table_or_column) raise '#identify method not available. #identifier_quote_character is certainly missing' end def connection @connection.raw_connection end def execute(query) @connection.execute query end def query(query) @connection.select_value query end def transaction @connection.transaction do yield end end def delete_all(table) execute "DELETE FROM #{identify(table)}" end def truncate(table) execute "TRUNCATE TABLE #{identify(table)}" end end end end
Version data entries
3 entries across 3 versions & 1 rubygems