We need to store the event participants and expenses persistently (e.g. in a database). We want to create an abstraction of the storage to allow for using different storage implementations. For instance, we may store the data in a relational database such as SQLite, or in a Google Datastore.
For the abstraction purposes we need an interface that defines a collection of methods to work with the storage, such as "insert a new participant" or 'get all expense records". There are no interfaces in Python language, however, it is possible to emulate them using classes with empty methods:
class Storage:
def __init__(self):
pass
def list_expense_records(self):
raise NotImplementedError
class InMemoryStorage(Storage):
def __init__(self):
Storage.__init__(self)
self.__expense_records = ["1:25:USD:john,paul,mick"] # Just for the demo purposes
def list_expense_records(self):
return self.__expense_records
The task is to design an interface that provides a collection of methods for storing the required data, and create two implementations of this interface: an in-memory one and one that stores data in an SQLite database. You can find a tutorial on working with SQLite here: https://www.digitalocean.com/community/tutorials/how-to-use-the-sqlite3-module-in-python-3
Please write some tests that use a storage implementation.
Please commit your code into a branchm create a pull request and assign a review to @dbarashev-jetbrains
We need to store the event participants and expenses persistently (e.g. in a database). We want to create an abstraction of the storage to allow for using different storage implementations. For instance, we may store the data in a relational database such as SQLite, or in a Google Datastore.
For the abstraction purposes we need an interface that defines a collection of methods to work with the storage, such as "insert a new participant" or 'get all expense records". There are no interfaces in Python language, however, it is possible to emulate them using classes with empty methods:
The task is to design an interface that provides a collection of methods for storing the required data, and create two implementations of this interface: an in-memory one and one that stores data in an SQLite database. You can find a tutorial on working with SQLite here: https://www.digitalocean.com/community/tutorials/how-to-use-the-sqlite3-module-in-python-3
Please write some tests that use a storage implementation.
Please commit your code into a branchm create a pull request and assign a review to @dbarashev-jetbrains