python - Using Django database layer outside of Django? -
I've got a good database in Django, and I want to interface with a python script I out of my website content , so I'm curious if it is possible to use the Django database API out of the Django site, and if so does anyone have any information on how this can be done? Google has not earned many hits for this.
Before you do you need to configure Django settings, including importing your model call something like this: django.conf import settings settings. configure the (DATABASE_ENGINE = 'postgresql_psycopg2', DATABASE_NAME = 'db_name', DATABASE_USER = 'db_user', DATABASE_PASSWORD = 'db_pass', DATABASE_HOST =
again, make sure you run to run the code, such as:
'localhost', 'DATABASE_PORT =' 5432 ', TIME_ZONE =' America / New_York ', ) Import from your_app.models
Then just Use DB API validly.
Comments
Post a Comment