Error when using frappe.db.get_list

i try to do customize script to get docs. i try to put frappe.db.get_list at firstly server side, there is error. and then i try to put into the js file. it has same error also.
in both error. looks the sql query has no fileds defined no matter i want to use default name or give some fields name

below is error when i put frappe.db.get_list at client side.

### Traceback

Syntax error in query:
select
from tabInspection Plan Content

		 order by `tabInspection Plan Content`.`modified` DESC
		limit 20 offset 0 

Traceback (most recent call last):
File “apps/frappe/frappe/app.py”, line 53, in application
response = frappe.api.handle()
File “apps/frappe/frappe/api.py”, line 53, in handle
return _RESTAPIHandler(call, doctype, name).get_response()
File “apps/frappe/frappe/api.py”, line 69, in get_response
return self.handle_method()
File “apps/frappe/frappe/api.py”, line 79, in handle_method
return frappe.handler.handle()
File “apps/frappe/frappe/handler.py”, line 48, in handle
data = execute_cmd(cmd)
File “apps/frappe/frappe/handler.py”, line 86, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “apps/frappe/frappe/init.py”, line 1591, in call
return fn(*args, **newargs)
File “apps/frappe/frappe/utils/typing_validations.py”, line 33, in wrapper
return func(*args, **kwargs)
File “apps/frappe/frappe/init.py”, line 796, in wrapper_fn
retval = fn(*args, **get_newargs(fn, kwargs))
File “apps/frappe/frappe/desk/reportview.py”, line 42, in get_list
data = execute(**args)
File “apps/frappe/frappe/desk/reportview.py”, line 64, in execute
return DatabaseQuery(doctype).execute(*args, **kwargs)
File “apps/frappe/frappe/model/db_query.py”, line 202, in execute
result = self.build_and_run()
File “apps/frappe/frappe/model/db_query.py”, line 242, in build_and_run
return frappe.db.sql(
File “apps/frappe/frappe/database/database.py”, line 222, in sql
self._cursor.execute(query, values)
File “env/lib/python3.10/site-packages/pymysql/cursors.py”, line 158, in execute
result = self._query(query)
File “env/lib/python3.10/site-packages/pymysql/cursors.py”, line 325, in _query
conn.query(q)
File “env/lib/python3.10/site-packages/pymysql/connections.py”, line 549, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File “env/lib/python3.10/site-packages/pymysql/connections.py”, line 779, in _read_query_result
result.read()
File “env/lib/python3.10/site-packages/pymysql/connections.py”, line 1157, in read
first_packet = self.connection._read_packet()
File “env/lib/python3.10/site-packages/pymysql/connections.py”, line 729, in _read_packet
packet.raise_for_error()
File “env/lib/python3.10/site-packages/pymysql/protocol.py”, line 221, in raise_for_error
err.raise_mysql_exception(self._data)
File “env/lib/python3.10/site-packages/pymysql/err.py”, line 143, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.ProgrammingError: (1064, “You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘from tabInspection Plan Content\n\t\t\t\n\t\t\t\n\t\t\t order by `tabInspection Plan Co…’ at line 2”)

### Request Data

{
“type”: “GET”,
“args”: {
“doctype”: “Inspection Plan Content”,
“fields”: “["name"]”,
“limit”: 20
},
“headers”: {},
“error_handlers”: {},
“url”: “/api/method/frappe.desk.reportview.get_list”
}

### Response Data

{
“exception”: “pymysql.err.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘from tabInspection Plan Content\n\t\t\t\n\t\t\t\n\t\t\t order by `tabInspection Plan Co…’ at line 2")”
}

Hi @k704790,

Please check its Database API Examples.

Thank You!

thanks

i finally found the reason, it is because the table/doc i am query is child table. and looks frappe.db.get_list() doesn’t support query child table.

Otherwise, you can also use frappe.db.sql

Thanks!