Skip to main content

Django like query for Flask-SQLAlchemy

Project description

Flask-DjangoQuery
=================

A module that implements a more Django like interface for Flask-SQLAlchemy query objects. It's still API compatible with the regular one but extends it with Djangoisms.

## Installation

Install Flask-DjangoQuery with pip:

$ [sudo] pip install Flask-DjangoQuery

Install Flask-DjangoQuery with easy_install:

$ [sudo] easy_install Flask-DjangoQuery

Or you can clone or download it then:

```bash
cd Flask-DjangoQuery
python setup.py install
```

## Usage

```python
from flask import Flask
from flask.ext.djangoquery import SQLAlchemy

app = Flask(__name__)

db = SQLAlchemy()
db.init_app(app)
```

Then you can use it just like [Flask-SQLAlchemy](https://github.com/mitsuhiko/flask-sqlalchemy) while have a more *Django like* `filter_by`, `exclude_by` and `order_by` interface.

### Define a model

```python
class Post(db.Model):
id = db.Column(db.Integer, primary_key=True)
pub_date = db.Column(db.Datetime)
title = db.Column(db.String(50))
```

## Example queries

```python
Post.query.filter_by(pub_date__year=2008)
Post.query.exclude_by(id=42)
Post.query.filter_by(title__contains='something')
Post.query.order_by('-post__pub_date')
```

For more please view the codes of [flask_djangoquery.py](flask_djangoquery.py)

Project details


Download files

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

Source Distributions

Flask-DjangoQuery-0.2.0.zip (7.2 kB view details)

Uploaded Source

Flask-DjangoQuery-0.2.0.tar.gz (4.3 kB view details)

Uploaded Source

File details

Details for the file Flask-DjangoQuery-0.2.0.zip.

File metadata

File hashes

Hashes for Flask-DjangoQuery-0.2.0.zip
Algorithm Hash digest
SHA256 7be7be229425a703aac7d2e5e89e273ed9777624fe673eb9e90289614895741a
MD5 3e52056fb485a5bacea453e7e0373535
BLAKE2b-256 9d1bc3d992c40055bf505faf2af73743c1b2e2e2d7bae1656300e7caff56e4b5

See more details on using hashes here.

File details

Details for the file Flask-DjangoQuery-0.2.0.tar.gz.

File metadata

File hashes

Hashes for Flask-DjangoQuery-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8ca80734afe8f202daefc1a96d74cac557d17fcebb16852657548c08c3cbc02c
MD5 c9577cb5ef308d8af054ac812d38c353
BLAKE2b-256 3ba424b026e1c80d8eb8ef6cf44a821bf6e23acb70715b60cb46e5cc522d16ad

See more details on using hashes here.

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