I am creating a cassandra table if the table does not exist with Python code below:
cluster = cassandra_cluster.Cluster([settings.CASSANDRA_CONTACT_POINT],
settings.CASSANDRA_PORT)
session = cluster.connect(settings.CASSANDRA_KEYSPACE)
session.execute("CREATE TABLE IF NOT EXISTS %s(id uuid PRIMARY
KEY,input text,predicted_result text,timestamp timestamp" % modelId)
When I set modelID = 12345, error appears in the terminal.
SyntaxException: <Error from server: code=2000 [Syntax error in CQL
query] message="line 1:27 no viable alternative at input '12345' (
CREATE TABLE IF NOT EXISTS [12345]...)">
What's wrong with my syntax?
Cassandra table name cannot started with numeric character. Encapsulate them with double quotes if need to do so. Eg. "12345"
or "%s"