Coder Social home page Coder Social logo

dbw's Introduction

DBW

DBW stands for 'DataBase Wrapper'. I could not find a better name, especially as it's both an ORM and a DAL.

DBW was created as part of another project of mine which needed an ORM, but i didn't like existing solutions.

It is a DAL (Database Abstraction Layer) and an ORM (Object-Relational Mapper) for Python 3.

The design is driven by the idea to have Python IDE autocomplete (static analysis) work. Also humans studying the code should not scratch their heads trying to understand from where an attribute has appeared in an object. Django ORM has too much magic - you have too look into docs to know all the params.

Some examples

We have a model:

class Book(Model):
    price = DecimalField(max_digits=10, decimal_places=2, default='0.00')

In Django you write:

Book.objects.filter(price__gte=10)

to select all books with price >= 10.

With DBW you do:

Book.objects.select(Book.price >= 10)

In Django you do:

Book.objects.filter(price__gte=10).values('id')

In DBW you write:

db.select(Book.id, where=(Book.price >= 10))

No need for QuerySet to chain filters, because where expressions can also be chained and they are, imo, more logical way for filtering objects.

In our case the code is trying to be self-explanatory. Using autocomplete and code following you can find out all params and their meaning.

Models and database tables are named in singular.

> I stick with Singular for table names and any programming entity. The reason? The fact that there are irregular plurals in English like mouse -> mice and sheep -> sheep. city -> cities ?

The code is in Beta state. It needs extensive testing. It is not thread-safe. It does not have caching yet.

I decided to release the code in its current state after watching "'Good Enough' is good enough!" by Alex Martelli at PyCon 2013:

Launch early, launch often!

dbw's People

Contributors

warvariuc avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.