Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 如何创建新数据库或连接到现有数据库_Python 3.x_Neo4j_Neo4j Driver - Fatal编程技术网

Python 3.x 如何创建新数据库或连接到现有数据库

Python 3.x 如何创建新数据库或连接到现有数据库,python-3.x,neo4j,neo4j-driver,Python 3.x,Neo4j,Neo4j Driver,我拉着neo4j docker运行: sudo docker run -p7474:7474 -p7687:7687 -e NEO4J_AUTH=neo4j/s3cr3t neo4j 从python中,我可以通过以下方式连接到它: scheme = "neo4j" host_name = "localhost" port = 7687 url = "{scheme}://{host_name}:{port}".format(schem

我拉着neo4j docker运行:

sudo docker run -p7474:7474 -p7687:7687 -e NEO4J_AUTH=neo4j/s3cr3t neo4j
从python中,我可以通过以下方式连接到它:

scheme = "neo4j"
host_name = "localhost"
port = 7687
url = "{scheme}://{host_name}:{port}".format(scheme=scheme, host_name=host_name, port=port)
user = "neo4j"
password = "s3cr3t"
driver = GraphDatabase.driver(url, auth=(user, password))
但是似乎没有API来选择我想要使用的
DB名称

  • 是否可以创建多个数据库(如
    postgres
    psycopg2
    connect
    函数和
    dbname
    ?)

  • 我希望能够创建两个不同的数据库(图),并通过python选择要使用的数据库(图)

  • 我怎么做


要连接到特定数据库,您可以在创建用于事务的时将数据库的名称作为的值传递

例如,要为名为“foo”的数据库创建会话:

...
driver = GraphDatabase.driver(uri, auth=(user, password))
session = driver.session(database="foo")
...