Giter VIP home page Giter VIP logo

django-manager-utils's Introduction

https://travis-ci.org/ambitioninc/django-manager-utils.png Latest PyPI version Number of PyPI downloads

django-manager-utils

Additional utilities for Django model managers.

Installation

To install the latest release, type:

pip install django-manager-utils

To install the latest code directly from source, type:

pip install git+git://github.com/ambitioninc/django-manager-utils.git

Documentation

Full documentation is available at http://django-manager-utils.readthedocs.org

License

MIT License (see LICENSE)

django-manager-utils's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-manager-utils's Issues

Expose manager utils functions that can be called independently

Currently manager utils requires that managers inherit MangerUtilsManager in order to take advantage of the functionality in manager utils.

Update the interface so that users can also do the following:

from manager_utils import bulk_upsert

bulk_upsert(queryset, list_of_upserts, unique_fields, update_fields)

Basically, the user should be able to provide querysets to all of the functions in manager utils. This is useful for models in third-party applications that do not inherit ManagerUtilsManager

Update Readme to mention database backends supported

I just spent an hour tried to debug an error only to find out that django-manager-utils doesn't support MySQL. This should be mentioned in the readme that MySQL is not supported. Submitting this issue to udpate Readme for the same.

Sync function

Create a sync() function. Similar to bulk_upsert, sync() should do a bulk_upsert() but also delete any objects not found in the queryset being synced. For example,

Account.objects.all().sync([list of accounts], unique_fields, update_fields)

After accounts have been synced, they should contain exactly the accounts in the list of accounts provided.

Support for DBMS Upsert expressions

Hey Wesley!

Nice work done here, congratulations...!

I was starting to write a code that is somewhat similar to the bulk_upsert function from your code, but relying on the native DBMS UPSERT implementations (PostgreSQL 9.5 specially), where instead of two separate queries (bulk_create and bulk_update), the whole operation would happen on a single upsert query.

Do you sometime have considered using it? I think this would be a great performance improvement for the Django ORM!

As soon as i have a more stable version of my code i'll let you know so you can maybe collaborate!

use bulk_upsert with MySQL

I am trying to use bulk_upsert with django ORM. I am using MySQL database as my backend. It does the insert part when some new rows are added but every time I triy to do an update using the update_fieldslist it throws an error complaining that the MySQL syntax is wrong:
'''
django.db.utils.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM (VALUES
'''

When I tried to debug this further I realized that manager_utils uses django-query-builder which is build for postgre sql by default.
Any help would be greatly appreciated. Thanks

Akshar Ranka

sqlite test support

There is sqlite support in the test rig, however there are imports and usage of JSONField and ArrayField, which are postgres specific fields.

Duplicates in bulk_upsert should raise error

In bulk upserts, the user needs to supply a uniqueness constraint. Right now manager provides allows duplicate entries for these uniqueness constraints in the input data.

It should actually throw an error when dups are found because such an input is actually invalid.

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.