create unmanaged model to oracle view/synonym

177 views
Skip to first unread message

Fabio C. Barrionuevo da Luz

unread,
Dec 31, 2014, 11:05:05 AM12/31/14
to django...@googlegroups.com
Hello, is possible with Django 1.7 create a unmanaged Django model for Oracle database View?

I succeeded in doing this using sqlalchemy, However, would like to use Django and Django ORM.

--
Fábio C. Barrionuevo da Luz
Acadêmico de Sistemas de Informação na Faculdade Católica do Tocantins - FACTO
Palmas - Tocantins - Brasil - América do Sul


Blog colaborativo sobre Python e tecnologias Relacionadas, mantido totalmente no https://github.com/pythonclub/pythonclub.github.io .

Todos são livres para publicar. É só fazer fork, escrever sua postagem e mandar o pull-request. Leia mais sobre como publicar em README.md e contributing.md.
Regra básica de postagem:
"Você" acha interessante? É útil para "você"? Pode ser utilizado com Python ou é útil para quem usa Python? Está esperando o que? Publica logo, que estou louco para ler...

Shai

unread,
Jan 1, 2015, 11:40:43 AM1/1/15
to django...@googlegroups.com
Hi Fábio,


On Wednesday, December 31, 2014 6:05:05 PM UTC+2, Fabio Caritas Barrionuevo da Luz wrote:
Hello, is possible with Django 1.7 create a unmanaged Django model for Oracle database View?



Yes. In your model's Meta, set managed to False and db_table to the view name:

class MyUnManagedModel(models.Model):
    # ...
    # fields
    # ...
    class Meta:
        managed = False
        db_table = 'view_name'

Have you run into difficulties?

HTH,
Shai.

Edgar Gabaldi

unread,
Jan 1, 2015, 2:57:38 PM1/1/15
to django...@googlegroups.com
Fabio,

Django ORM support Oracle Database[1].

If you want connect an existing oracle database, i recomend you see the inspectdb management command.



--
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/bf043f16-043a-4f0f-a6bf-2856c405be43%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Message has been deleted
Message has been deleted

Fabio Caritas Barrionuevo da Luz

unread,
Jan 2, 2015, 9:05:24 AM1/2/15
to django...@googlegroups.com
Hello, Shai and Edgar

yes, I've tried using inspectdb, however, it only generates models for database tables, but not for database View[1] and database Synonym[2].

The Django documentation is currently not explicit in showing that the specific database features are supported by Django database backends.

inspectdb does not support "database schemas"[3][4].

Any other ideas how to solve this?




-- 
Fábio C. Barrionuevo da Luz
Acadêmico de Sistemas de Informação na Faculdade Católica do Tocantins - FACTO
Palmas - Tocantins - Brasil - América do Sul



Collin Anderson

unread,
Jan 4, 2015, 2:26:33 PM1/4/15
to django...@googlegroups.com
Hi,

What happens when you try Shai's suggestion?

class MyUnManagedModel(models.Model):
   
# ...
   
# fields
   
# ...
   
class Meta:
        managed
= False
        db_table
= 'view_name'

Collin

Sunil Naik

unread,
Feb 16, 2017, 7:34:36 AM2/16/17
to Django users
Thanks Collin, it worked for me.
Reply all
Reply to author
Forward
0 new messages