3

My plan is to be able to dynamically generate SQL tables. Since I know django can create SQL tables using models, they must have a function for this. The problem is I can not find this function in the Django folder, or maybe I simply don't recognize it. thnx

1

3 Answers 3

2

It's called django-admin.py

Start here: http://docs.djangoproject.com/en/dev/ref/django-admin/

Specifically, see http://docs.djangoproject.com/en/dev/ref/django-admin/#django-admin-sql

Sign up to request clarification or add additional context in comments.

2 Comments

I'm looking for the specific function actually. This way I can implement it in my python script.
@Benjamin: You can import and execute that. Further, you can read the source to see how they do it. It's quite clear from reading the source.
2

I am not exactly sure what you mean, but you can get the SQL for all the tables in an app by running this command: python manage.py sqlall your_app

1 Comment

It's sqlmigrate now
1

If you're looking for the specific pieces of code, have a look at django.db.backends.base.creation to see how the sql is generated, of course there need to be individual implementations for different database types, so for example also see django.db.backends.postgresql_psycopg2.creation!

1 Comment

Can you fix the broken link?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.