Skip to main content

Marguerite provides a declarative, consistent accessor to data layer.

Project description

Marguerite

Marguerite provides a declarative, consistent accessor to data layer.


Dependencies

  • Python 2.7 or later

  • Werkzeug 0.12.7 or later

Usage Flow.

  1. define formater. ```python from marguerite import AbstractFormater, Order

class User(AbstractFormater): struct = { “id” : int(), “name” : str(), “email” : str(), }

orders = Order( user = “”” SELECT * FROM table WHERE id = :id “””,

users = """
    SELECT
        *
    FROM
        __table__
    WHERE
        id in (:ids)
"""

) ```

  1. get data layer accessor object ```python from marguerite import Marguerite, AbstractAccessor from marguerite.accessors import bind

class Accessor(AbstractAccessor): def get(self, name, value={}): order = self.formater.get_order(name) return bind(order, value)

marguerite = Marguerite(None, Accessor) accessor = marguerite.get_accessor(“path.to.User”) ```

  1. fetch data ```python # as dict result = accessor.get(“user”, { “id”: 1 }) print(result) # result “”” SELECT

    • FROM table WHERE id = 1 “””

as array

result = accessor.find(“users”, { “ids”: [1, 2] }) print(result) # result “”” SELECT * FROM table WHERE id in (1, 2) “”” ```

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Marguerite-1.0.0.tar.gz (3.7 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page