Code

Opened 7 years ago

Closed 7 years ago

#5454 closed (fixed)

Using a user-built DB backend

Reported by: George Vilches <gav@…> Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords: database backend sprintsept14
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: UI/UX:

Description

Since the DB backend refactoring, creating your own backend package has been easier than ever. Installing your customized backend in the Django source doesn't make sense, so the intention here is to be able to reference the backend somewhere outside the Django source.

This was discussed here with some favorable results on the django-dev list: http://groups.google.com/group/django-developers/browse_thread/thread/6bdfac9b1eac8d63/9ef5a73a61671cbd?lnk=gst&q=george+vilches&rnum=1#9ef5a73a61671cbd

Attachments (2)

user_backend_r6186.patch (3.1 KB) - added by George Vilches <gav@…> 7 years ago.
Adds support for specifying a user backend against r6186.
user_backend_r6284.patch (3.5 KB) - added by George Vilches <gav@…> 7 years ago.
Moved global variables to curried functions.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 7 years ago by George Vilches <gav@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from Using a project specific backend to Using a user-built DB backend

Changed 7 years ago by George Vilches <gav@…>

Adds support for specifying a user backend against r6186.

comment:2 Changed 7 years ago by George Vilches <gav@…>

  • Has patch set

The provided patch allows you to reference the backend in your settings.py file by putting a module path in DATABASE_ENGINE.

An example (assume I have an package in my path called 'db_backends', which contains a package called test1 that contains a fully-involved backend):

#DATABASE_ENGINE = 'mysql'
DATABASE_ENGINE = 'db_backends.test1'
DATABASE_NAME = 'test_db'
DATABASE_USER = 'test_user'

Either of the above DATABASE_ENGINE statements work with this patch. If you provide a package that doesn't exist, Django fails and returns the error message it always has.

comment:3 Changed 7 years ago by George Vilches <gav@…>

Sorry, screwed up the example:

#DATABASE_ENGINE = 'mysql' 
DATABASE_ENGINE = 'db_backends.test1' 
DATABASE_NAME = 'test_db' 
DATABASE_USER = 'test_user'

comment:4 Changed 7 years ago by George Vilches <gav@…>

  • Keywords sprintsept14 added

comment:5 Changed 7 years ago by russellm

  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Accepted

Like the idea, like the interface - don't like the patch. get_creation_module and get_introspection_module now have a dependence on import_path, a global variable. This should probably be curried into the functions, rather than be left as a global reference.

Changed 7 years ago by George Vilches <gav@…>

Moved global variables to curried functions.

comment:6 Changed 7 years ago by George Vilches <gav@…>

The current patch against r6284 removed the dependence on import path via django.utils.functional.curry.

comment:7 Changed 7 years ago by jacob

  • Resolution set to fixed
  • Status changed from new to closed

(In [6316]) Fixed #5454: settings.DATABASE_BACKEND may now refer to an external package (i.e. one located outside the Django source. Thanks, George Vilches.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.