MySql Memory tables doubt...

52 views
Skip to first unread message

Jose Galvan

unread,
Mar 16, 2016, 7:45:37 PM3/16/16
to Django users
Hi,

I am developing a web site to make queries and create new entries  in a old Mysql order entry system so I need to use the Raw SQL django functionality more than ORM.

In the process I need to use a temporary mysql table ( like a memory table that  is alive while the session is active), my question is : In order to manipulate it, Do I need to declare this table in the models.py like any other table ?

Anybody with experience in this ?

Any guidance will be greatly appreciated.

TIA

Jose

René Fleschenberg

unread,
Mar 19, 2016, 6:57:00 AM3/19/16
to django...@googlegroups.com
Hi,

On Wednesday 16 March 2016 12:58:17 Jose Galvan wrote:
> I am developing a web site to make queries and create new entries in a
> old Mysql order entry system so I need to use the Raw SQL django
> functionality more than ORM.

Are you sure that you cannot use the ORM? Maybe you can just use unmanaged
models?

https://docs.djangoproject.com/ja/1.9/ref/models/options/#managed

> In the process I need to use a temporary mysql table ( like a memory table
> that is alive while the session is active), my question is : In order to
> manipulate it, Do I need to declare this table in the models.py like any
> other table ?

Take a look at Django's multi-database support:

https://docs.djangoproject.com/en/1.9/topics/db/multi-db/

Yes, you should probably write models for the temporary table.

--
René

Jose Galvan

unread,
Mar 19, 2016, 3:24:25 PM3/19/16
to Django users
Thanks for your Answer Rene, Well you see.. tables were designed without Id primary key on it, instead tables use composed keys, ORM queries in Django are mostly based on an unique Id  feature as Pk, this was the main reason for not to use ORM. And yes, tables are declared as manage=false, in fact when I did execute migrate command django got all DB phisical structures and automatically created models in models.py and added the feature you mention..manage= "FALSE" as a metadata in each model

Anyway, regarding temporary tables  I was testing and it seems to be not necessary to declare it on models.py, the error I had was for another reason.

Thanks very much man !
Reply all
Reply to author
Forward
0 new messages