class FluentQuery::Drivers::MySQL

MySQL database driver.

Public Instance Methods

driver_name() click to toggle source

Returns the DBI driver name. @return [String] driver name

# File lib/fluent-query/drivers/mysql.rb, line 42
def driver_name
    "Mysql"
end
known_token?(group, token_name) click to toggle source

Indicates token is known.

Calls superclass method
# File lib/fluent-query/drivers/mysql.rb, line 29
def known_token?(group, token_name)
    super(group, token_name, @@__known_tokens)
end
native_connection() click to toggle source

Returns native connection.

Calls superclass method
# File lib/fluent-query/drivers/mysql.rb, line 67
def native_connection

    super()

    # Gets settings
    encoding = @_nconnection_settings[:encoding]
    
    if encoding.nil?
        encoding = "utf8"
    end

    # Sets encoding and default schema
    @_nconnection.do("SET NAMES " + self.quote_string(encoding) + ";")

    return @_nconnection
    
end
open_connection(settings) click to toggle source

Opens the connection.

It’s lazy, so it will open connection before first request through {@link native_connection()} method.

Calls superclass method
# File lib/fluent-query/drivers/mysql.rb, line 54
def open_connection(settings)
    if not settings[:database] or not settings[:username]
        raise FluentQuery::Drivers::Exception::new("Database name and username is required for connection.")
    end
    
    super(settings)
end
quote_identifier(field) click to toggle source

Quotes field by field quoting.

# File lib/fluent-query/drivers/mysql.rb, line 90
def quote_identifier(field)
    '`' + field.to_s.gsub(".", '`.`') + '`'
end