Home > database >  Do I need to create a model for a table I'm inserting through sqlalchemy in django?
Do I need to create a model for a table I'm inserting through sqlalchemy in django?

Time:02-06

I have a Command class that runs an api call to a coin market cap api and writes it into the database that I have rigged up to my django project called cryptographicdatascience. The table that the data is written to is called apis_cmc and is not defined in my models.py.

My question is if I am writing straight to a table using sqlalchemy do I need to go in and create a model for the same table in my models.py file?

It seems to me that the answer is no but I'm sure there is something I'm overlooking.

Thanks, Justin

CodePudding user response:

No, there is no need to create table in models.py as it is not a part of a Django ORM.

But have in mind, that Django ORM won't know about your table and won't store any data in migration files. It can cause some problems on deploy stage or when you move to other working machine.

  •  Tags:  
  • Related