The docs state:
Specify the target database on all queries, either with the database_ parameter in Driver.execute_query() or with the database parameter when creating new sessions. If no database is provided, the driver has to send an extra request to the server to figure out what the default database is. The overhead is minimal for a single query, but becomes significant over hundreds of queries.
and gives 2 examples:
# Good practice
driver.execute_query("<QUERY>", database_="<DB NAME>")
driver.session(database="<DB NAME>")
# Bad practice
driver.execute_query("<QUERY>")
driver.session()
Does that mean that
# Good practice
driver.execute_query("<QUERY>", database_="<DB NAME>")
driver.session()
and this
# Good practice
driver.execute_query("<QUERY>")
driver.session(database="<DB NAME>")
are good practices or should I specify the database name in execute_query()
and session()
?
The documentation could be a bit clearer.
driver.execute_query
and driver.session
actually represent 2 different ways to execute queries. You would use one call or the other, but not together.
It would have been clearer for the documentation to say something like:
# Good practice
driver.execute_query("<QUERY>", database_="<DB NAME>")
OR
driver.session(database="<DB NAME>")
# Bad practice
driver.execute_query("<QUERY>")
OR
driver.session()