I have an Oracle DB. There is data. And so I do not understand when I generate a Model B Django or Hibernate. This all creates a kind of copy of the existing table, but does not synchronize with it - right? The question is generally about ORM. That is, by creating classes they synchronize with the database (in which there is already data) or create a new one and already map there?
1 answer
In general, an ORM is a spacer between the object and table view of data. As such, this pad does not copy the data (otherwise it would result in redundant data duplication).
On the example of Django. After you describe the data model in Django, and synchronize
python manage.py syncdb
Django ORM will deduce the structure of the database from the description of models and bring the base in accordance with them. Ultimately, the model is a kind of "virtual" entity, while the base tables are "real".
- It's clear. But when I write a new application and there are no tables in the database, they are created after all. And when is there synced? or how? - boom_
- Yes exactly. When not, they are created when they are synchronized. However, when changes are made to the model, you may need to migrate the database. - Nicolas Chabanovsky ♦
- not quite the right opinion about syncdb, it only creates tables that are not yet existing in the database, but does not change them ... [proof to docks] [1] [1]: docs.djangoproject.com/en/dev/ref/django- admin / # syncdb - sonniy
|