1

我正在尝试使用 python 创建一个 monetdb 数据库。数据库一开始不存在:代码应该创建它,指定端口,它将驻留的文件夹和数据库名称。我可以清楚地假设数据库已经存在的所有示例。在某种程度上,这应该类似于通常由 moneddbd 守护程序管理的操作。如何从头开始在 python 中设置(新)monetdb 数据库?

4

1 回答 1

2

一种方法是:

import monetdb.control

control=control.Control(port=port,passphrase=None)
control.create(database)
control.release(database)

另一种方式(我的方式):

import subprocess

farm_path="/home/me/..."
database_name="test"
subprocess.call("monetdbd create "+farm_path,shell=True,executable="/bin/bash")
subprocess.call("monetdbd start "+farm_path,shell=True,executable="/bin/bash")
subprocess.call("monetdb create "+database_name,shell=True,executable="/bin/bash")
subprocess.call("monetdb release "+database_name,shell=True,executable="/bin/bash")

如果您想要更详细的代码,请告诉我。

于 2015-01-27T15:03:47.720 回答