简体   繁体   English

如何在python中从头开始设置(新)monetdb数据库?

[英]How to setup a (new) monetdb db from scratch in python?

I'm trying to create a monetdb db with python. 我正在尝试使用python创建一个monetdb数据库。 The db doesn't exist at the beginning: the code should create it specifying the port, the folder were it will reside & the db name. db开头不存在:代码应创建该数据库,并指定端口,它将驻留的文件夹和db名称。 All the examples I could fine clearly assume that the db exists already. 我可以罚款的所有示例都清楚地假设该数据库已经存在。 In some way this should be similar to the operations typically managed by the moneddbd deamon. 在某种程度上,这应该类似于moneddbd deamon通常管理的操作。 How do I setup a (new) monetdb db in python from scratch? 如何从头开始在python中设置一个(新的)monetdb数据库?

One way to do it is: 一种方法是:

import monetdb.control

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

Another way (my way): 另一种方式(我的方式):

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")

If you want a bit more detailed code, let me know. 如果您需要更详细的代码,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM