SyntaxError: Invalid syntax

Hello Guys!

Need your help on this,

Thanks.

I received error
Route
List/Meeting
Error Report
    Traceback (most recent call last):
      File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 62, in application
        response = frappe.handler.handle()
      File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 22, in handle
        data = execute_cmd(cmd)
      File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 53, in execute_cmd
        return frappe.call(method, **frappe.form_dict)
      File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 939, in call
        return fn(*args, **newargs)
      File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/load.py", line 71, in getdoctype
        docs = get_meta_bundle(doctype)
      File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/load.py", line 81, in get_meta_bundle
        bundle = [frappe.desk.form.meta.get_meta(doctype)]
      File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/meta.py", line 24, in get_meta
        meta = FormMeta(doctype)
      File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/meta.py", line 34, in __init__
        self.load_assets()
      File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/meta.py", line 44, in load_assets
        self.load_templates()
      File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/meta.py", line 159, in load_templates
        module = load_doctype_module(self.name)
      File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/utils.py", line 185, in load_doctype_module
        doctype_python_modules[key] = frappe.get_module(module_name)
      File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 704, in get_module
        return importlib.import_module(modulename)
      File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
        __import__(name)
      File "/home/frappe/frappe-bench/apps/meeting/meeting/meeting/doctype/meeting/meeting.py", line 24
        existing_records=frappe.db.sql(""" select name from TabMeeting Schedule where from_time>='{0}' and to_time<='{1}' """.format(self.from_time,self.from_time)as_list=True)
                       ^
    SyntaxError: invalid syntax
    Request Data
    {
    	"type": "GET",
    	"args": {
    		"doctype": "Meeting",
    		"with_parent": 1,
    		"cached_timestamp": null,
    		"cmd": "frappe.desk.form.load.getdoctype"
    	},
    	"freeze": true,
    	"url": "/"
    }
    Response JSON
    {}

Sorry about that guys, i’m new with ERPNext
Thanks,
@Foxdemon96

hii
use tabMeeting Schedule like this:

it doesnt count space without this upper quotes, and t is always small in tab.

I think you are missing a comma before as_list = True

Hi @lokesh

I try use upper quotes and small t on tabMeeting Schedule but I still receive syntax error

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 62, in application
    response = frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 22, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 53, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 939, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/load.py", line 71, in getdoctype
    docs = get_meta_bundle(doctype)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/load.py", line 81, in get_meta_bundle
    bundle = [frappe.desk.form.meta.get_meta(doctype)]
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/meta.py", line 24, in get_meta
    meta = FormMeta(doctype)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/meta.py", line 34, in __init__
    self.load_assets()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/meta.py", line 44, in load_assets
    self.load_templates()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/meta.py", line 159, in load_templates
    module = load_doctype_module(self.name)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/utils.py", line 185, in load_doctype_module
    doctype_python_modules[key] = frappe.get_module(module_name)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 704, in get_module
    return importlib.import_module(modulename)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/frappe/frappe-bench/apps/meeting/meeting/meeting/doctype/meeting/meeting.py", line 24
    existing_records=frappe.db.sql(""" select name from 'tabMeeting Schedule' where from_time>='{0}' and to_time<='{1}' """.format(self.from_time,self.from_time)as_list=True)
                   ^
SyntaxError: invalid syntax

Regards,
@Foxdemon96

Hi @root13F,

I try to add comma before as_list=True

but still receive syntax error

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 62, in application
    response = frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 22, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 53, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 939, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/load.py", line 71, in getdoctype
    docs = get_meta_bundle(doctype)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/load.py", line 81, in get_meta_bundle
    bundle = [frappe.desk.form.meta.get_meta(doctype)]
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/meta.py", line 24, in get_meta
    meta = FormMeta(doctype)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/meta.py", line 34, in __init__
    self.load_assets()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/meta.py", line 44, in load_assets
    self.load_templates()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/meta.py", line 159, in load_templates
    module = load_doctype_module(self.name)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/utils.py", line 185, in load_doctype_module
    doctype_python_modules[key] = frappe.get_module(module_name)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 704, in get_module
    return importlib.import_module(modulename)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/frappe/frappe-bench/apps/meeting/meeting/meeting/doctype/meeting/meeting.py", line 24
    existing_records=frappe.db.sql(""" select name from tabMeeting Schedule where from_time>='{0}' and to_time<='{1}' """.format(self.from_time,self.from_time),as_list=True)
                   ^
SyntaxError: invalid syntax

regards,
@Foxdemon96

hiii
sorry for miscommunication,
i mean tilde not quotes.
Use tilde key instead of quotes.

This is not an SQL error but a Python syntax error for sure.

check for any indentation errors around existing_records

Also as @lokesh is mentioning, please use tilde ( ` ) signs to enclose your table name. Write it like this :

“`tabMeeting Schedule`”

I think that is not the exact problem but just to be sure.

Hey,
I think you should try your query on bench mysql , if there will be any error in query it will show there
like
select name from tabMeeting Schedule where from_time>=‘2018-11-1’ and to_time<=‘2018-11-13’ ;

Hi @pooja.m

I already try

regards,
@Foxdemon96

Hi @root13F and @lokesh

I still receive

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 62, in application
    response = frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 22, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 53, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 939, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/load.py", line 71, in getdoctype
    docs = get_meta_bundle(doctype)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/load.py", line 81, in get_meta_bundle
    bundle = [frappe.desk.form.meta.get_meta(doctype)]
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/meta.py", line 24, in get_meta
    meta = FormMeta(doctype)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/meta.py", line 34, in __init__
    self.load_assets()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/meta.py", line 44, in load_assets
    self.load_templates()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/meta.py", line 159, in load_templates
    module = load_doctype_module(self.name)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/utils.py", line 185, in load_doctype_module
    doctype_python_modules[key] = frappe.get_module(module_name)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 704, in get_module
    return importlib.import_module(modulename)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/frappe/frappe-bench/apps/meeting/meeting/meeting/doctype/meeting/meeting.py", line 24
    existing_records=frappe.db.sql(""" select name from "`tabMeeting Schedule`" where from_time>='{0}' and to_time<='{1}'""".format(self.from_time,self.from_time),as_list=True)
                   ^
SyntaxError: invalid syntax

Thanks for your time.

regards,
@Foxdemon96

just use like below, no double quote.
image

hi @magic-overflow

I Still receive same error

regards,
@Foxdemon96

Can you print-screen your code from line 20 to 26?
from this file: /home/frappe/frappe-bench/apps/meeting/meeting/meeting/doctype/meeting/meeting.py

why you used the from_time Two times in .format of query

existing_records=frappe.db.sql(""" select name from “tabMeeting Schedule” where from_time>=’{0}’ and to_time<=’{1}’""".format

(self.from_time,self.from_time)

,as_list=True)

Hi @magic-overflow

regards,
@Foxdemon96

Something wrong with your double and single quote.
image
image
image

image

you should use self.to_time in your .format() after self.from_time

He’s trying to get existing meeting which from_time happen in between from_time to to_time.

Hi @lokesh

I still receive same error

regards,
@Foxdemon96

hi @magic-overflow

sorry but I can’t guess what I supposed to do.

I hope you can help me on this.

Thanks

Regards,
@Foxdemon96