Neo4j source
NEO4JSource
Bases: DataSource
Source code in blue/data/sources/neo4j_source.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | |
execute_query(query, database=None, collection=None)
Execute a Cypher query against the Neo4j database.
This method sends the provided Cypher query to the connected Neo4j instance and returns the results. It does not limit execution to a single transaction or single record.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
The Cypher query string to execute. |
required |
database
|
str
|
Name of the database to target. Defaults to None. |
None
|
collection
|
str
|
Name of the collection/schema. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
|
list[dict]: A list of dictionaries representing query results, |
|
|
where each dictionary corresponds to a record returned by the query. |
Source code in blue/data/sources/neo4j_source.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | |
extract_schema(nodes_result, relationships_result, rel_properties_result)
Build a DataSchema object from query results describing nodes, relationships, and relationship properties.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nodes_result
|
list[dict]
|
List of node definitions with labels and properties. |
required |
relationships_result
|
list[dict]
|
List of relationship definitions. |
required |
rel_properties_result
|
list[dict]
|
List of relationship property definitions. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
DataSchema |
A schema object representing entities and relations. |
Source code in blue/data/sources/neo4j_source.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
fetch_database_collection_entities(database, collection)
Fetch all entities (nodes) in a specific Neo4j database collection.
This method retrieves the database schema and extracts the entities (node labels) present in the specified collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
str
|
Name of the database. |
required |
collection
|
str
|
Name of the collection (usually same as database). |
required |
Returns:
| Type | Description |
|---|---|
|
list[dict]: A list of entity definitions, each representing a node |
|
|
with its properties in the Neo4j database. |
Source code in blue/data/sources/neo4j_source.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
fetch_database_collection_metadata(database, collection)
Fetch metadata for a specific collection (database) in Neo4j.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
str
|
Name of the database. |
required |
collection
|
str
|
Name of the collection (usually same as database). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Metadata for the collection. Default implementation returns empty dict. |
Source code in blue/data/sources/neo4j_source.py
142 143 144 145 146 147 148 149 150 151 152 153 | |
fetch_database_collection_relations(database, collection)
Fetch all relationships (edges) in a specific Neo4j database collection.
This method retrieves the database schema and extracts the relationships between entities present in the specified collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
str
|
Name of the database. |
required |
collection
|
str
|
Name of the collection (usually same as database). |
required |
Returns:
| Type | Description |
|---|---|
|
list[dict]: A list of relationship definitions, each representing |
|
|
a relationship type along with its source and target nodes. |
Source code in blue/data/sources/neo4j_source.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
fetch_database_collections(database)
Retrieve the collections (databases or logical groupings) for a Neo4j database.
In Neo4j, each database is treated as a single collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
str
|
Name of the database. |
required |
Returns:
| Type | Description |
|---|---|
|
list[str]: List containing the database name as the collection. |
Source code in blue/data/sources/neo4j_source.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
fetch_database_metadata(database)
Fetch metadata for a specific database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
str
|
Name of the database. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Metadata for the database (default empty). |
Source code in blue/data/sources/neo4j_source.py
100 101 102 103 104 105 106 107 108 109 110 | |
fetch_database_schema(database)
Fetch the schema for a specific Neo4j database, including node labels and relationship types.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
str
|
Name of the database. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Schema information including nodes and relationships. |
|
|
Default implementation returns empty dict. |
Source code in blue/data/sources/neo4j_source.py
112 113 114 115 116 117 118 119 120 121 122 123 124 | |
fetch_databases()
Retrieve the list of available databases from the source.
Returns:
| Type | Description |
|---|---|
|
list[str]: Names of all databases. |
Source code in blue/data/sources/neo4j_source.py
86 87 88 89 90 91 92 93 94 95 96 97 98 | |
fetch_metadata()
Fetch high-level metadata for the Neo4j source.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Metadata about the source. |
|
|
Default implementation returns empty dict. |
Source code in blue/data/sources/neo4j_source.py
65 66 67 68 69 70 71 72 73 | |
fetch_schema()
Fetch the global schema definition from the Neo4j source.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Schema information including nodes and relationships. |
|
|
Default implementation returns empty dict. |
Source code in blue/data/sources/neo4j_source.py
75 76 77 78 79 80 81 82 83 | |