Error when monkey patch in custom app?

ii tried to import db from custom app

from frappe import db

it is showing this error,erpnext not able to load

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/website/”, line 39, in render
data = render_page_by_language(path)
File “/home/frappe/frappe-bench/apps/frappe/frappe/website/”, line 119, in render_page_by_language
translated_languages = frappe.get_hooks(“translated_languages_for_website”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/”, line 832, in get_hooks
hooks = _dict(cache().get_value(“app_hooks”, load_app_hooks))
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/”, line 73, in get_value
self.set_value(original_key, val, user=user)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/”, line 41, in set_value
self.set(key, pickle.dumps(val))
File “/home/frappe/frappe-bench/env/lib/python2.7/”, line 77, in _reduce_ex
raise TypeError("a class that defines slots without "
TypeError: a class that defines slots without defining getstate cannot be pickled