Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-04-2020 04:41 PM
Hi,
I am using Neo4j Desktop 1.3.11 on Windows.
Am using apoc.export.csv.query()
to get my query results via py2neo
. This outputs the csv file to the "import" folder of the DB.
Understand it is possible to navigate to the DB's "import" folder by clicking the 'Open Folder' button in Neo4j Desktop. However, I would like to do so programmatically, since my program is aware of the DB's name e.g. neo4j-db
, instead of manually specifying the DB's folder location, which naming can be quite obtuse e.g. C:\Users\[username]\AppData\Local\Neo4j\Relate\Data\dbmss\dbms-db3c8764-9a9c-xxx
I did a couple of searches on Google as one in this community forum, but didn't find anything that can do that.
Is there a way, perhaps to call the system
graph to check the folder path?
Or perhaps I'm asking the wrong qn -> Is there a way to specify an arbitrary location in Windows to output my csv?
Solved! Go to Solution.
12-04-2020 05:54 PM
To be more complete:
Call dbms.listConfig() YIELD name, value
WHERE name='dbms.directories.import'
RETURN value
value contains the string of the import directory.
You can also set your import directory in configs
dbms.directories.import=
dbms.directories.import=ABSOLUTE_DIRECTORY_PATH
Also see:
12-04-2020 04:54 PM
cypher
Call dbms.listConfig();
Should list all config parameters and values. You should be able to get import dir from here
12-04-2020 05:54 PM
To be more complete:
Call dbms.listConfig() YIELD name, value
WHERE name='dbms.directories.import'
RETURN value
value contains the string of the import directory.
You can also set your import directory in configs
dbms.directories.import=
dbms.directories.import=ABSOLUTE_DIRECTORY_PATH
Also see:
02-14-2022 08:27 AM
Hi,
Slight tweak to the solution. This call just produces the relative path of the import folder.
Call dbms.listConfig() YIELD name, value
WHERE name='dbms.directories.import'
RETURN value
The returned values is "import" which is probably not the intent of the request which I take to need the full path.
This returns the full path:
Call dbms.listConfig() YIELD name, value
WHERE name='dbms.directories.neo4j_home'
RETURN value
and since the folder structure is fixed by the database creation process and the import folder name is "import" so that needs to be added to the end of the returned string.
So this is where I ended up with
def get_import_path(tx):
result= tx.run("Call dbms.listConfig() YIELD name, value WHERE name='dbms.directories.neo4j_home' RETURN value")
return [record["value"] for record in result]
with driver.session() as session:
Neo4JImport = session.read_transaction(get_import_path)[0]+'/import'
driver.close()
Neo4JImport
Andy
10-24-2022 08:33 AM - edited 10-24-2022 09:07 AM
For Version 5.1.0 we should use server.directories.neo4j_home instead of home.directories.neo4j_home
11-28-2022 04:43 PM - edited 11-28-2022 04:45 PM
This solution seems like it may evolve over time. I found a working solution for v1.5.4 by investigating the configs with this query
CALL dbms.listConfig()
YIELD name, value
WHERE name CONTAINS 'import'
RETURN name, value
ORDER BY name
LIMIT 40;
And that led me to the name of the config at this time. So this gives me the location of the local import directory in one shot:
CALL dbms.listConfig()
YIELD name, value
WHERE name = 'server.directories.import'
RETURN value
All the sessions of the conference are now available online