Neo4j source
NEO4JSource
Bases: DataSource
Source code in blue/data/sources/neo4j_source.py
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 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | |
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
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | |
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
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 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
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
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
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
188 189 190 191 192 193 194 195 196 197 198 199 | |
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
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | |
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
173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
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
146 147 148 149 150 151 152 153 154 155 156 | |
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
158 159 160 161 162 163 164 165 166 167 168 169 170 | |
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
132 133 134 135 136 137 138 139 140 141 142 143 144 | |
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
111 112 113 114 115 116 117 118 119 | |
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
121 122 123 124 125 126 127 128 129 | |