Class: HPgSql
Instance Attribute Summary
Attributes inherited from HDB
#connection, #resultTable, #sth, #table
Instance Method Summary
collapse
Methods inherited from HDB
HDB, #closeConnection, #columnCount, #data, #delete, destroy, #direction, #execute, #from, #insert, #insertValues, #limit, #method_missing, newHDB, #normalizeWhereFormat, #offset, #openConnection, #orderBy, #primitiveType?, #queryStr, #quote, #quoteValue, #rowCount, #select, #show, #toClassName, #update, #updateValues, #where
Constructor Details
#initialize(host, port, dbname, user, password, timezone, connectionName) ⇒ HPgSql
Returns a new instance of HPgSql.
5
6
7
8
9
10
|
# File 'lib/hdb/hpgsql.rb', line 5
def initialize(host, port, dbname, user, password, timezone, connectionName)
super(host, port, dbname, user, password, timezone, connectionName, "hpgsql")
@result = nil
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class HDB
Instance Method Details
#_execute(queryStr = self.queryStr) ⇒ Object
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/hdb/hpgsql.rb', line 28
def _execute(queryStr = self.queryStr)
@table = []
@result = @connection.query(queryStr)
@result.each do |row|
@table << row
end
return self
end
|
#connect ⇒ Object
12
13
14
15
16
17
18
19
|
# File 'lib/hdb/hpgsql.rb', line 12
def connect()
@connection = PGconn.new(@host, @port, "", "", @dbname, @user, @password)
hl << "Server version: #{self.execute("SHOW server_version").firstData.to_s}"
self.execute("SET TIME ZONE '#{@timezone}'") if @timezone
return @connection
end
|
#disconnect ⇒ Object
21
22
23
24
25
26
|
# File 'lib/hdb/hpgsql.rb', line 21
def disconnect()
@connection.close()
@connection = nil
end
|
#fieldNameList ⇒ Object
39
40
41
42
43
44
45
46
47
|
# File 'lib/hdb/hpgsql.rb', line 39
def fieldNameList()
fieldList = {}
@result.fields.each { |fieldName| fieldList[fieldName] = nil }
return fieldList
end
|
#rowsAffected ⇒ Object
49
50
51
|
# File 'lib/hdb/hpgsql.rb', line 49
def rowsAffected
return @result.cmd_tuples()
end
|