Executing aql query from python client


#1

Is there a way to execute the aql query directly from the Python Client? Like directly execute “select * from test” without using the provided select function in the Python client.

Thanks!


#2

AQL is application written using the Aerospike C Client - the Aerospike Python client utilizes the C client as well. So running AQL inside Python does not make sense. All that you can do via AQL, you can directly do via Python Client calls.


#3

My question might not be clear. I am asking if there is some function, say run_query(query), that accepts a string as an argument where the string is actually an AQL query. I understand I can use the provided functions but then I have to additionally do some string parsing which I would like to avoid.

Thanks!


#4

The answer is no. Aerospike does not understand AQL query syntax. AQL parses the text you type … interpretting “INSERT” as a put() call, ignoring “INTO”, picking namespace, setname, key (form PK) arguments and then your bin names and values - forms and sends the C API call to Aerospike. Aerospike Python client does not have AQL syntax interpreter built in it.

However, AQL does take a text file input. Look at RUN command on AQL> prompt or the -f command line option in aql. You can stack all your AQL commands in a text file and “run” it … if that helps with what you are trying to do.