[英]How should i pass username and password to Cassandra using python script
I am new to python programming, I am trying to build a script that will take Casandra metadata backup.我是 python 编程的新手,我正在尝试构建一个脚本来备份 Casandra 元数据。 My script is working fine when there is authentication configured in yaml file but it failed when we turned on authentication.
当 yaml 文件中配置了身份验证时,我的脚本工作正常,但是当我们打开身份验证时它失败了。
This is the part where I am calling CQLSH.这是我调用 CQLSH 的部分。
with open(save_path + '/' + filename, 'w') as f:
query_process = subprocess.Popen(['echo', query], stdout=subprocess.PIPE)
cqlsh = subprocess.Popen(('/bin/cqlsh', host),
stdin=query_process.stdout, stdout=f)
query_process.stdout.close()
return (save_path + filename)
It will be really helpful for me if anyone can help.如果有人可以提供帮助,这对我真的很有帮助。
Depending on your configuration and deployment there are a couple of options.根据您的配置和部署,有几个选项。
You might just choose to pass them as command line options to your popen
command.您可能只是选择将它们作为命令行选项传递给您的
popen
命令。
Another alternative is to have them in a cqlshrc
file, which is either read from the standard location ( ~/.cassandra/cqlshrc
), or an alternative path passed as another command line option .另一种选择是将它们放在
cqlshrc
文件中,该文件可以从标准位置 ( ~/.cassandra/cqlshrc
) 读取,也可以作为另一个命令行选项传递的替代路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.