access legacy data without model.py

2 views
Skip to first unread message

dundeemt

unread,
Dec 12, 2009, 10:24:36 AM12/12/09
to Django users
I need to access data in other databases. I don't want them listed in
model.py as I won't be using django's orm for them. Given this, where
is the preferred place to put the db connection for this data? The
only references I could find show creating a db connection in the
view, http://www.djangobook.com/en/beta/chapter05/ -- while valid for
my purposes, is there a better place to cache the connection?

Also, I will be accessing 7+ other databases of varying types, some
have hundreds of tables and I have no desire to create a model when
for them when I only need to get to a few values. I will not be
updating data in these other databases, only doing lookups. So I am
not interested in making a proper django data connection to them.



Best,

Jeff

rebus_

unread,
Dec 13, 2009, 5:22:25 AM12/13/09
to django...@googlegroups.com
2009/12/12 dundeemt <dund...@gmail.com>:
> --

In upcoming 1.2 version of django there should be support for multiple
database. Thought Django 1.2 is scheduled for release on March 9,
2010.

More information:

http://code.djangoproject.com/wiki/Version1.2Roadmap
http://code.djangoproject.com/wiki/Version1.2Features
http://code.djangoproject.com/wiki/MultipleDatabaseSupport
http://code.djangoproject.com/ticket/1142

Sorry i can't be more helpfull.

Davor

dundeemt

unread,
Dec 13, 2009, 4:29:41 PM12/13/09
to Django users


On Dec 13, 4:22 am, rebus_ <r.dav...@gmail.com> wrote:
> 2009/12/12 dundeemt <dunde...@gmail.com>:
>
>
>
>
>
> > I need to access data in other databases.  I don't want them listed in
> > model.py as I won't be using django's orm for them. Given this, where
> > is the preferred place to put the db connection for this data?  The
> > only references I could find show creating a db connection in the
> > view,http://www.djangobook.com/en/beta/chapter05/ -- while valid for
> > my purposes, is there a better place to cache the connection?
>
> > Also, I will be accessing 7+ other databases of varying types, some
> > have hundreds of tables and I have no desire to create a model when
> > for them when I only need to get to a few values.  I will not be
> > updating data in these other databases, only doing lookups.  So I am
> > not interested in making a proper django data connection to them.
>
> > Best,
>
> > Jeff
>
> > --
>
> In upcoming 1.2 version of django there should be support for multiple
> database. Thought Django 1.2 is scheduled for release on March 9,
> 2010.
>
> More information:
>
> http://code.djangoproject.com/wiki/Version1.2Roadmaphttp://code.djangoproject.com/wiki/Version1.2Featureshttp://code.djangoproject.com/wiki/MultipleDatabaseSupporthttp://code.djangoproject.com/ticket/1142
>
> Sorry i can't be more helpfull.
>
> Davor
Thanks for responding. I've read through the 1.2 info so I have seen
that, but it doesn't appear to be what I am after.

Best,

Jeff

Nick Arnett

unread,
Dec 13, 2009, 4:49:14 PM12/13/09
to django...@googlegroups.com

I think that good design practice would be to create a data access module for this purpose and import it when you need it.  I've done this a few times for MySQL access and even wrapped some of the more frequent patterns and queries into methods in that module. 

Nick

Reply all
Reply to author
Forward
0 new messages