Class: Blazer::Adapters::Neo4jAdapter
Instance Attribute Summary
Attributes inherited from BaseAdapter
#data_source
Instance Method Summary
collapse
Methods inherited from BaseAdapter
#cachable?, #cancel, #cohort_analysis_statement, #cost, #explain, #initialize, #reconnect, #schema, #supports_cohort_analysis?
Instance Method Details
#preview_statement ⇒ Object
32
33
34
|
# File 'lib/blazer/adapters/neo4j_adapter.rb', line 32
def preview_statement
"MATCH (n:{table}) RETURN n LIMIT 10"
end
|
#run_statement(statement, comment) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/blazer/adapters/neo4j_adapter.rb', line 4
def run_statement(statement, )
columns = []
rows = []
error = nil
begin
result = session.query("#{statement} /*#{}*/")
columns = result.columns.map(&:to_s)
rows = []
result.each do |row|
rows << columns.map do |c|
v = row.send(c)
v = v.properties if v.respond_to?(:properties)
v
end
end
rescue => e
error = e.message
end
[columns, rows, error]
end
|
#tables ⇒ Object
27
28
29
30
|
# File 'lib/blazer/adapters/neo4j_adapter.rb', line 27
def tables
result = session.query("CALL db.labels()")
result.rows.map(&:first)
end
|