Reputation: 6888
I want to migrate a site written in PHP/MySQL to a Python/Django. There will be some significant modifications to the application, but I am not expecting any significant changes to the backend persistence.
Essentially I would like to find a tool that will create the
django.db.models.Model
classes for me. For example consider:
create table blah (
a varchar(10) not null
, b varchar(10) not null
)
and I run the tool and it generates the following models.py file for me
class Blah(models.Model):
a = models.CharField(max_length=10)
b = models.CharField(max_length=10)
Something I can run command line OR wherever. Thanks, and I am new to python/django so I apologize if there is well known solution (although google isn't showing me one).
T
Upvotes: 2
Views: 83
Reputation: 473873
Django can handle it, see inspectdb management command:
Introspects the database tables in the database pointed-to by the NAME setting and outputs a Django model module (a models.py file) to standard output.
Also, consider using south for further schema and data migrations.
Upvotes: 2