Skip to content

Commit

Permalink
Merge pull request #21 from micahhausler/newfeature/query-connection
Browse files Browse the repository at this point in the history
Newfeature/query connection
  • Loading branch information
somewes committed Jul 28, 2014
2 parents c25b337 + ce106a6 commit 52af41d
Show file tree
Hide file tree
Showing 25 changed files with 704 additions and 264 deletions.
3 changes: 1 addition & 2 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
branch = True
omit =
querybuilder/migrations/*
querybuilder/tests/*
querybuilder/version.py
source = querybuilder
[report]
Expand All @@ -12,5 +11,5 @@ exclude_lines =

# Don't complain if tests don't hit defensive assertion code:
raise NotImplementedError
fail_under = 87
fail_under = 92
show_missing = True
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ env:
matrix:
- DJANGO=1.6.5
install:
- pip install -q coverage flake8 Django==$DJANGO
- pip install -q coverage coveralls flake8 Django==$DJANGO
before_script:
- psql -c 'CREATE DATABASE querybuilder;' -U postgres
script:
- flake8 .
- coverage run setup.py test
- coverage report --fail-under=87
- coverage report --fail-under=92
after_success:
coveralls
13 changes: 12 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
.. image:: https://travis-ci.org/ambitioninc/django-query-builder.png
:target: https://travis-ci.org/ambitioninc/django-query-builder

.. image:: https://coveralls.io/repos/ambitioninc/django-query-builder/badge.png?branch=develop
:target: https://coveralls.io/r/ambitioninc/django-query-builder?branch=develop

.. image:: https://pypip.in/v/django-query-builder/badge.png
:target: https://crate.io/packages/django-query-builder/
:alt: Latest PyPI version

.. image:: https://pypip.in/d/django-query-builder/badge.png
:target: https://crate.io/packages/django-query-builder/

django-query-builder
====================
querybuilder is a django library for assisting with the construction and
Expand All @@ -24,7 +34,8 @@ where django querysets simplify the sql generation process for simple queries.

Requirements
------------
* Python 2.7+
* Python 2.7
* Python 3.3, 3.4
* Django 1.4+

Installation
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def get_version():

intersphinx_mapping = {
'python': ('http://python.readthedocs.org/en/v2.7.2/', None),
'django': ('http://django.readthedocs.org/en/latest/', None),
'django': ('http://django.readthedocs.org/en/1.7.x/', None),
#'celery': ('http://celery.readthedocs.org/en/latest/', None),
}

Expand Down
4 changes: 2 additions & 2 deletions docs/ref/fields.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _ref-fields:

fields
======
Field API documentation
=======================

.. automodule:: querybuilder.fields

Expand Down
4 changes: 2 additions & 2 deletions docs/ref/query.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _ref-query:

query
=====
Query API documentation
=======================

.. automodule:: querybuilder.query

Expand Down
4 changes: 2 additions & 2 deletions docs/ref/tables.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _ref-tables:

tables
======
Tables API documentation
========================

.. automodule:: querybuilder.tables

Expand Down
6 changes: 6 additions & 0 deletions docs/release_notes.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Release Notes
=============

v0.5.8
------

* Added connection parameter to query for multiple database support
* flake8 cleanup

v0.5.7
------

Expand Down
19 changes: 19 additions & 0 deletions docs/usage_examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,25 @@ Inner queries
inner_query = Query().from_table(Account)
outer_query = Query().from_table(inner_query)
Connection Setup
----------------

Arbitrary django connections can be passed into the Query constructor to connect to alternate databases.

.. code-block:: python
from django.db import connections
from querybuilder.query import Query
connections.all()
#[<django.db.backends.postgresql_psycopg2.base.DatabaseWrapper at 0x1127b4390>,
# <django.db.backends.postgresql_psycopg2.base.DatabaseWrapper at 0x1127b44d0>]
Query(connections.all()[0]).from_table('auth_user').count()
# 15L
Query(connections.all()[1]).from_table('auth_user').count()
# 223L
Reference Material
------------------
* http://www.postgresql.org/docs/9.1/static/functions-window.html
Loading

0 comments on commit 52af41d

Please sign in to comment.