简体   繁体   English

我应该如何使用 python 脚本将用户名和密码传递给 Cassandra

[英]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.

相关问题 如何在python中将用户名和密码传递给cassandra - How to pass along username and password to cassandra in python 如何在 python 脚本中使用 sudo su - 用户名并将密码传递给它 - how to use sudo su - username in python script and pass password to it python命令行参数并将其作为用户名和密码在脚本中传递 - python command line argument and pass it as username and password in script 在 python 中,如何将用户名和密码从变量传递到 python 中的 cx_Oracle.connect - In python how can I pass the username and password from a variable to cx_Oracle.connect in python 我应该使用sqlite3通过python存储用户名和密码吗? - Should I use sqlite3 for storing username and password with python? 需要使用密码连接 cassandra 的脚本并使用 python 执行 CQL - Need Script for connecting cassandra with password and execute CQL using python 使用 Python GUI 的密码和用户名 - Password and Username using Python GUI 我如何通过python使用用户名和密码创建SSL连接服务器? - How i could to make SSl Connection server using username, password by python? 如何使用密钥而不是基本身份验证用户名和密码将Python连接到RESTful API? - How do I connect with Python to a RESTful API using keys instead of basic authentication username and password? 使用Python脚本更改Linux用户名或密码 - Changing Linux username or password with Python script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM