Reading from resource with `.read()`
.read()¶
Retriving data from resource (db) is done using .read() method
Read is called from resource of table property (table property is called from object of epure)
Read takes either key-word arguments or result of creating query with @escript decorator (read abput @escript here):
Using .read()
from epure import epure, escript
@epure()
class MyEpure:
    str_field:str
    @classmethod
    @escript
    def my_query_creator(cls):
        query = cls.md.str_field == "a key-word arg"
...
# creating and saving instances
...
Key-word approach
Or@escript decorator approach
Using read() with **kwargs parameters¶
**kwargs with read() is convinient when you:
- 
know attribute by which you want to get set of objects 
- 
have data_id(UUID) of specific object
Then you can use .read() method that takes key-word arguments and allows this ready to hand approach of getting objects:
Using read() with **kwargs
We will take data_id (UUID) from saved object:
UUID as data_id kwarg will return object with that specific UUID:
# reading by unique data_id of article will return one object
my_articles = obj1.table.read(data_id=article_one_data_id)[0] # -> [<Article object at 0x0...>]
object:
# multiple attrs of article
my_articles = Article.resource.read(str_attr="Why Epure is the best ORM?", times_published=3) # -> [[<Article object at 0x0...,>, ...]]
- data_id is a unique UUID object identifier that Epure uses to discriminate different objects