Not sure what you mean. Are you looking to build the model definitions in your models.py files, or are you trying to take the results of a query against MSSQL and pass them to a constructor for a model that has already been defined?
Either way, eventually you'll end up with a copy of the 'model' in your local DB assuming that you save the model, not sure if that is your intention or not. And it likely will not be a fun process if the data sets you are pulling do not have a similar structure to abstract into a unified model (or couple of models), which sounds like it may be the case if you have extensive data queries that both follow foreign keys or many-to-many relationships. -James On Tue, Jan 20, 2015 at 8:02 AM, Fred <[email protected]> wrote: > I've got a complex 1000+ table vendor read-only MS SqlServer database and > only have SELECT privileges. I can connect with pymssql no problem. > > Of all these tables, I probably care about 50 or less. > > I cannot create views unless I introduce another physical server and use > the "Linked Server" option. There are several administrative and > performance hurdles to this. > > This DB is not clearly documented, so I have to explore and refine my > SELECT statement for each query. I'm typically ending up with 5...10 joins > per query. > > Most relationships are Foreign Keys although a few are many-to-many. > > I've searched without success for a way to "encapsulate" a complex SELECT > statement into a django model definition. > > Is there any way to do this within the django model framework? > > > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > 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/8cc80725-083a-406e-a6cb-725ff6a2222c%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/8cc80725-083a-406e-a6cb-725ff6a2222c%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. To post to this group, send email to [email protected]. 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/CA%2Be%2BciXBti6qnL1wiDcnfPyU8Z%2BcAm1dafL3j0Cjwju6ESMmaw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

