def exists(self, dt, dn=None):
		if isinstance(dt, basestring):
			if dt!="DocType" and dt==dn:
				return True # single always exists (!)
			try:
				return self.get_value(dt, dn, "name")
			except:
				return None
		elif isinstance(dt, dict) and dt.get('doctype'):
			try:
				conditions = []
				for d in dt:
					if d == 'doctype': continue
					conditions.append('`%s` = "%s"' % (d, cstr(dt[d]).replace('"', '\"')))
				return self.sql('select name from `tab%s` where %s' % \
						(dt['doctype'], " and ".join(conditions)))
			except:
				return None
Returns true if document exists.
dataset/ETHPy150Open frappe/frappe/frappe/database.py/Database.exists