def delete(self): """ Run the delete """ delete = Delete("orders") delete.equals("author_id", self._author_id) delete_record(delete)
def test_delete_record(self): mp = {"a": "integer"} _db = Database.instance(":memory:", "test_table", mp) keys = mp.keys() create = Create("test_table", keys) create_records(keys, create, [{"a": 1}, {"a": 2}]) sel = Select("test_table", ["a"]) sel.less_than_or_equal_to("a", 3) rvals = [] for r in get_record(sel): rvals.append(r) d = Delete("test_table") d.greater_than("a", 1) delete_record(d) sel = Select("test_table", ["a"]) sel.less_than_or_equal_to("a", 3) rvals = [] for r in get_record(sel): rvals.append(r)
class DeleteUser(object): """ ORM for deleting a user """ def __init__(self): """ Constructor """ self._delete = Delete("users") def by_author_id(self, author_id): """ Deletes users with the given author_id :param author_id: author_id to delete by """ self._delete.equals("author_id", author_id) def in_city(self, city): """ Deletes users in the given city :param city: The city """ self._delete.equals("city", city) def in_state(self, state): """ Deletes users in the given state :param state: The state """ self._delete.equals("state", state) def in_zip(self, zip): """ Deletes users in the given zip code :param zip: The zip code """ self._delete.equals("zip", zip) def delete(self): """ Delete the record """ delete_record(self._delete) self._delete = Delete("users")
def test_delete(self): delete = Delete("test_table") delete.less_than("i", 100) assert str(delete) == "DELETE FROM test_table WHERE i < 100"
def delete(self): """ Run the delete """ delete_record(self._delete) self._delete = Delete("orders")
def __init__(self): """ Constructor """ self.delete = Delete("orders")
def delete(self): """ Delete the record """ delete_record(self._delete) self._delete = Delete("users")
def __init__(self): """ Constructor """ self._delete = Delete("users")