neo4j / neo4j-python-driver

Neo4j Bolt driver for Python
https://neo4j.com/docs/api/python-driver/current/
Other
899 stars 186 forks source link

Config Attribute "database" does not have an effect. #383

Closed Buchhold closed 4 years ago

Buchhold commented 4 years ago

Env

python 3.8 neo4j-driver 4.0.0a2 Neo4j Server version: 4.0.2 (enterprise) -- using the 30 day trial, atm

I have create several "databases" through the browser and can successfully switch in the Neo Browser via :use. Both, CREATE and MATCH statements work as I'd expect. However, I cannot switch through the driver.

Steps to reproduce

driver = neo4j.GraphDatabase.driver( "bolt://host:7687", auth=(usr, pw), encrypted=False)
s1 = driver.session()
s2 = driver.session(database='mytest')

s1._config:

<SessionConfig consume_chain=<function Config.consume_chain at 0x7fa86682f670> consume=<bound method Config.consume of <class 'neo4j.conf.WorkspaceConfig'>> connection_acquisition_timeout=60.0 max_retry_time=30.0 initial_retry_delay=1.0 retry_delay_multiplier=2.0 retry_delay_jitter_factor=0.2 database=None fetch_size=1000 bookmarks=() default_access_mode='WRITE'>

s2._config:

<SessionConfig consume_chain=<function Config.consume_chain at 0x7fa86682f670> consume=<bound method Config.consume of <class 'neo4j.conf.WorkspaceConfig'>> connection_acquisition_timeout=60.0 max_retry_time=30.0 initial_retry_delay=1.0 retry_delay_multiplier=2.0 retry_delay_jitter_factor=0.2 database='mytest' fetch_size=1000 bookmarks=() default_access_mode='WRITE'>
r = s2.run("match () return count(*)")
print(r.data())

Expected behavior

print the number of nodes in mytest

Actual behavior

prints the number of nodes in the default database

CREATE statements made with the session object target the default DB, too.

martin-neotech commented 4 years ago

@Buchhold you are correct, multidatabase support is not implemented yet, I'm working on it right now. It is estimated to be an alpha release 4.0.0a3 that includes the multidatabase support next week. Please be patient and dont hesitate to give feedback.

Cheers Martin

technige commented 4 years ago

@Buchhold The third alpha was released last week, so you should now be able to trial the multidb functionality.

martin-neotech commented 4 years ago

This is available in the alpha release now.

driver.session(database="my_other_database")