I'm trying to create user in cassandra using python driver
.
defined variable password
password=abcde
rows = session.execute("create user test_user with 'password')
Syntax error in CQL query] message="line password expecting K_PASSWORD
password=abcde
rows = session.execute("create user test_user with 'password')
You're missing the PASSWORD
reserved word in your syntax. Also, CREATE USER
is only used with versions of Cassandra prior to 3.x. It's CREATE ROLE
if you're on a version after that.
Versions below 3.x
CREATE USER test_user WITH PASSWORD 'abcde';
3.x+
CREATE ROLE test_user WITH PASSWORD='abcde';
Note that the newer versions require the password and PASSWORD
to be separated by an equals ('=') symbol.
So in your Python script, it'd look something like this:
rows = session.execute("create role test_user with password='" + password1 + "' and login=true")