Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ucm.execute_sql_query can't run. #7

Open
yuexp001 opened this issue May 28, 2020 · 3 comments
Open

ucm.execute_sql_query can't run. #7

yuexp001 opened this issue May 28, 2020 · 3 comments

Comments

@yuexp001
Copy link

Hello
I got an error message 'axl' object has no attribute 'execute_sql_query' when I try it run SQL query.

@Insigna2020
Copy link

Insigna2020 commented Jul 30, 2020

I have not tested it yet but it looks like the documentation have some typos. I can see on the code that if you need to execute a sql query, you will need to do "sql_query(your_query)" and if you need to update the database, you will need to use "sql_update(your_update_query)" both takes one argument. Code snippet from axl.py:

def sql_query(self, query):
    """
    Execute SQL query
    :param query: SQL Query to execute
    :return: result dictionary
    """
    try:
        return self.client.executeSQLQuery(query)["return"]
    except Fault as e:
        return e

def sql_update(self, query):
    """
    Execute SQL update
    :param query: SQL Update to execute
    :return: result dictionary
    """
    try:
        return self.client.executeSQLUpdate(query)["return"]
    except Fault as e:
        return e

@Randle-Lanre
Copy link

@yuexp001 @Insigna2020 did you later get a fix for this, there was some typos in the documentation and running

def sql_query(self, query):

kept returning 'NoneType' object is not iterable

@htjmetcalf
Copy link

I was able to work around this by adding the ['rows'] after my SQL statement. The issue is the return has a parent element called <rows></rows> We cannot iterate over the <return></return> tag because it only contains one item, which is <rows> but we can iterate over the <rows> element.

Also changed from Execute to Run in the Function Call.

I'll work on fixing this in the axl.py and forking it, but I've never done that before. Also, a quick note that this library is fantastic, and I am thankful for the time and effort that has gone into it.

Execute SQL Query

for sql in ucm.run_sql_query('select * from device where description like "Bart%"')['rows']:
    print(sql['name'])

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

No branches or pull requests

4 participants