简体   繁体   中英

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. My script is working fine when there is authentication configured in yaml file but it failed when we turned on authentication.

This is the part where I am calling 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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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