I am attempting to build a django based web page (I know python and want to develop a couple web based applicaitons). The goal of this page is to show data from a few different databases that I only have read access to. Basically, it is dashboard type view for a couple key things.
I've build a Sqlite database to hold the Django settings for the application. How do I branch out from here though? I'd like to query an Oracle database and a MySQL database?
I can query them individually using something like this in an appropriate view:
def test(request):
from django.db import load_backend
myBackend = load_backend('django.db.backends.oracle') # or 'mysql', 'sqlite3', 'oracle'
myConnection = myBackend.DatabaseWrapper({
'HOST': 'myhost',
'NAME': 'mysid',
'OPTIONS': {},
'PASSWORD': "mypass",
'PORT': "1521",
'USER': "myuser",
'TIME_ZONE': "America/Chicago"})
# Now we can do all the standard raw sql stuff with myConnection.
myCursor = myConnection.cursor()
myCursor.execute("SELECT COUNT(1) FROM schema.table;")
return HttpResponse("%s." % myCursor.fetchone())
In the template I can display this count. However, this seems incorrect, based on how I can query the Sqlite database.
I'd like to use a data model. Is this the appropriate thing to use when I am just reading data? The account doesn't have write access to the oracle/mysql tables.
Is there a way to automatically generate these models for the existing tables? Some of these tables are rather large in terms of number of columns and, if possible, I'd prefer to automate the create to prevent mistakes on my part.