Pythonでmonetdb dbを作成しようとしています。データベースは最初は存在しません。コードは、ポート、存在するフォルダー、およびデータベース名を指定して作成する必要があります。私がうまくできるすべての例は、データベースがすでに存在することを明確に想定しています。ある意味で、これは moneddbd デーモンによって通常管理される操作に似ているはずです。Python で (新しい) monetdb db を最初からセットアップするにはどうすればよいですか?
1 に答える
2
それを行う1つの方法は次のとおりです。
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 に答える