big legacy database with complex many to many relationships

71 views
Skip to first unread message

Sells, Fred

unread,
Feb 24, 2014, 2:54:35 PM2/24/14
to django...@googlegroups.com

I have to integrate to a large read only legacy mssql database .

 

The many-to-many tables have a lot of additional fields like start/end dates of the relationship and their own naming conventions

 

Can anyone point me to some links that treat this topic in depth.  I’ve looked at the django book and that’s a starting point,

 

Can anyone point me to some good “how to” links on this that provide some details and some pitfalls to watch for.

 

Thanks

 

Fred.

Javier Guerra Giraldez

unread,
Feb 24, 2014, 3:12:01 PM2/24/14
to django...@googlegroups.com
On Mon, Feb 24, 2014 at 2:54 PM, Sells, Fred
<fred....@adventistcare.org> wrote:
> I have to integrate to a large read only legacy mssql database .


while certainly it's possible to configure this as a second database
and use the ORM, I've found that it's more work than usually needed.
especially if you already have defined SQL patterns, or worse, stored
procedures. porting those to ORM means debugging them again...

but there's nothing preventing you from using any Python way to access
that data. particularly if you're going to treat it as read-only.
just write some utility functions that use ODBC or any other interface
to pull your data and use that in your Django views, or even in your
models.

--
Javier

Sells, Fred

unread,
Feb 24, 2014, 4:57:11 PM2/24/14
to django...@googlegroups.com
Thanks, I think you set me on the right track.

Fred.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFkDaoS1WBGDN80v5J%2BCh%2BXCx_g1SD2obvjG51AqO_YJA0mM7w%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Tom Evans

unread,
Feb 24, 2014, 5:35:57 PM2/24/14
to django...@googlegroups.com
At $JOB we have very successfully integrated django into our existing
(homebrew) C++ ORM and web framework - we do new development in
django, and gradually the C++ code diminishes (only 390k LOC to go!).
Our objects are beyond complex, a typical item has some 100+ M2M
relationships, often with extra data in the join table. Django can
handle this mostly fine, I suppose the one caveat is that our
pre-existing system modelled very closely the database structure that
django would have used.

So if your data is nicely BCNF already, you shouldn't have many
problems. The Django docs has a section on integrating with legacy
databases, don't bother looking at it, it suggests to use inspectdb..

Instead, model your objects and then write django model classes for
them, one by one, setting the appropriate field and meta options so
that it finds the right tables and columns for that model. Lather,
rinse, repeat until all your models are done.

Cheers

Tom
Reply all
Reply to author
Forward
0 new messages