Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

Insert queries #42

Open
George3d6 opened this issue Jul 31, 2018 · 1 comment
Open

Insert queries #42

George3d6 opened this issue Jul 31, 2018 · 1 comment

Comments

@George3d6
Copy link

Could you give some examples of insert queries ?

Something like this

    executable_query = cassandra.prepare("""INSERT INTO units (date, marks, user_id) VALUES (%s, %s, %s)""", (date,marks,user_id,))
    await cassandra.execute_future(executable_query)

or this:

    executable_query = cassandra.prepare("""INSERT INTO units (date, marks, user_id) VALUES (%s, %s, %s)""")
    await cassandra.execute_future(executable_query, (date,marks,user_id,))

fails with the error:

cassandra.protocol.SyntaxException: <Error from server: code=2000 [Syntax error in CQL query] message="line 1:49 no viable alternative at character '%'">

@George3d6
Copy link
Author

Nevermind, works by replacing %s with ?, the sync cassandra prepare syntax... kind of obvious in hindsight.

Still, would you mind adding a line exemplifying this in the README ? (for people like myself, who haven't used the sync library before, it might help a bit, since the docs of the sync library mention the %s syntax first and this one doesn't mention the subject of inserting values)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant