Class: MiniSql::Connection
- Inherits:
-
Object
- Object
- MiniSql::Connection
show all
- Defined in:
- lib/mini_sql/connection.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.get(raw_connection, options = {}) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/mini_sql/connection.rb', line 6
def self.get(raw_connection, options = {})
if (defined? ::PG::Connection) && (PG::Connection === raw_connection)
Postgres::Connection.new(raw_connection, options)
elsif (defined? ::ArJdbc)
Postgres::Connection.new(raw_connection, options)
elsif (defined? ::SQLite3::Database) && (SQLite3::Database === raw_connection)
Sqlite::Connection.new(raw_connection, options)
elsif (defined? ::Mysql2::Client) && (Mysql2::Client === raw_connection)
Mysql::Connection.new(raw_connection, options)
else
raise ArgumentError, 'unknown connection type!'
end
end
|
Instance Method Details
#build(sql) ⇒ Object
42
43
44
|
# File 'lib/mini_sql/connection.rb', line 42
def build(sql)
Builder.new(self, sql)
end
|
#escape_string(str) ⇒ Object
46
47
48
|
# File 'lib/mini_sql/connection.rb', line 46
def escape_string(str)
raise NotImplementedError, "must be implemented by child connection"
end
|
#exec(sql, *params) ⇒ Object
34
35
36
|
# File 'lib/mini_sql/connection.rb', line 34
def exec(sql, *params)
raise NotImplementedError, "must be implemented by child connection"
end
|
#query(sql, *params) ⇒ Object
30
31
32
|
# File 'lib/mini_sql/connection.rb', line 30
def query(sql, *params)
raise NotImplementedError, "must be implemented by child connection"
end
|
#query_hash(sql, *params) ⇒ Object
38
39
40
|
# File 'lib/mini_sql/connection.rb', line 38
def query_hash(sql, *params)
raise NotImplementedError, "must be implemented by child connection"
end
|
#query_single(sql, *params) ⇒ Object
Returns a flat array containing all results. Note, if selecting multiple columns array will be flattened
26
27
28
|
# File 'lib/mini_sql/connection.rb', line 26
def query_single(sql, *params)
raise NotImplementedError, "must be implemented by child connection"
end
|