Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-29-2021 01:46 PM
I used to only create one database so I used the default database name 'neo4j-default'. Now I need to create one more database, and I want to explicitly give the db a name. How to do that?
I thought I should change this line:
my_driver = GraphDatabase.driver(self.uri, auth=(self.username, self.password), encrypted=False)
But it doesn't seem to have a parameter to give the DB a name. How to do that? My community version is 4.0.4.
09-30-2021 01:55 AM
Is this the official Python driver or the Py2Neo?
If it's the official one you can do this:
with driver.session(database="example_database", fetch_size=100) as session:
result = session.run("MATCH (a:Person) RETURN a.name AS name")
# do something with the result...
More information here:
https://neo4j.com/docs/api/python-driver/current/api.html?highlight=database#session-construction
And here:
https://neo4j.com/docs/api/python-driver/current/api.html?highlight=database#database-ref
If you are using Py2Neo, there's an optional "nam" parameter to state which Database you'd like to connect.
10-01-2021 11:03 AM
I am using Python official bolt api. Regarding the 'fetch_size',
The fetch size used for requesting messages from Neo4j.
Does this mean for each cypher request, or read_transaction, it returns the number of fetch_size records from the DB? How is it related to the 'limit' keyword in cypher statement?
10-01-2021 02:28 PM
with driver.session(database="example_database", fetch_size=100) as session:
result = session.run("MATCH (a:Person) RETURN a.name AS name")
Actually, I was asking for how to create a db with a db name, not how to connect to a specific db. This statement below gives me the 'default' neo4j db name:
my_driver = GraphDatabase.driver(self.uri, auth=(self.username, self.password), encrypted=False)
All the sessions of the conference are now available online