2016-10-19 5 views
2

私はPythonのサブプロセスを通じてHBaseにアクセスする簡単なコマンドを試しています。 次のコードは私に間違って出力できます:代わりに私のHBaseのテーブルのリストを与えるのHBaseにアクセスするためのサブプロセスの使用

import subprocess 
cmd=['hbase','shell','list'] 
subprocess.call(cmd) 

を、私は次のような出力を得る:

Usage: hbase [<options>] <command> [<args>] 
Options: 
    --config DIR Configuration direction to use. Default: ./conf 
    --hosts HOSTS Override the list in 'regionservers' file 

Commands: 
Some commands take arguments. Pass no args or -h for usage. 
shell   Run the HBase shell 
hbck   Run the hbase 'fsck' tool 
snapshot  Create a new snapshot of a table 
snapshotinfo Tool for dumping snapshot information 
wal    Write-ahead-log analyzer 
hfile   Store file analyzer 
zkcli   Run the ZooKeeper shell 
upgrade   Upgrade hbase 
master   Run an HBase HMaster node 
regionserver Run an HBase HRegionServer node 
zookeeper  Run a Zookeeper server 
rest   Run an HBase REST server 
thrift   Run the HBase Thrift server 
thrift2   Run the HBase Thrift2 server 
clean   Run the HBase clean up script 
classpath  Dump hbase CLASSPATH 
mapredcp  Dump CLASSPATH entries required by mapreduce 
pe    Run PerformanceEvaluation 
ltt    Run LoadTestTool 
version   Print the version 
CLASSNAME  Run the class named CLASSNAME 

をどのように私はサブプロセスのコマンドを与えていますか?

+0

私はhbaseシェルが実際に対話的なシェルを期待していると確信しています。 – orion78fr

答えて

0

PythonからHBaseにアクセスする必要がある場合は、happybaseモジュールをご覧ください。

私は過去4年間の生産でそれらを使用しており、ETLタスクを簡略化しています。箱から出して

彼らはしかし、数分の作業で、Pythonの2.Xある - (あなたのデータはUTF-8である場合に便利)あなたは、Python 3にアップグレードすることができ

+0

happybaseを使用してテーブルの名前を変更できますか?ドキュメントで見つけたのは、HBaseの読み書き方法です。 – anonymous

+0

これは接続で可能なドキュメントを読みましたが、これを許可する方法はありません。申し訳ありません –

+0

私は接続で可能なドキュメントを読んでいますが、これを許可する方法はありません。ハッピーベースは、トランジションインターフェース(http://wiki.apache.org/hadoop/Hbase/ThriftApi)を使用していますが、このインターフェースにはスナップショット、clone_snapshot、およびdelete_snapshotは含まれていません(あなたが推測しているステップあなたの名前を変更するために使用する)。幸せな基本層の欠陥ではありません。 –

0

方法を考え出しました。私は以下のようなコマンドを含むシェルファイルを作成しました:

echo 'list' | hbase shell -n 

Ran this in Python。

関連する問題