#NEWLINE# def django_models( self , metadata_source = None ) : #NEWLINE# #INDENT# sql = self . sql ( dialect = 'postgresql' , inserts = False , creates = True , drops = True , metadata_source = metadata_source ) #NEWLINE# u = sql . split ( ';\n' ) #NEWLINE# try : #NEWLINE# #INDENT# import django #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# print ( 'Cannot find Django on the current path. Is it installed?' ) #NEWLINE# django = None #NEWLINE# #UNINDENT# if django : #NEWLINE# #INDENT# from django.conf import settings #NEWLINE# from django.core import management #NEWLINE# from django import setup #NEWLINE# import sqlite3 #NEWLINE# import os #NEWLINE# db_filename = 'generated_db.db' #NEWLINE# conn = sqlite3 . connect ( db_filename ) #NEWLINE# c = conn . cursor ( ) #NEWLINE# for i in u : #NEWLINE# #INDENT# c . execute ( i ) #NEWLINE# #UNINDENT# if ( not settings . configured ) : #NEWLINE# #INDENT# settings . configure ( DEBUG = 'on' , SECRET_KEY = '1234' , ALLOWED_HOSTS = 'localhost' , DATABASES = { #NEWLINE# #INDENT# 'default' : { #NEWLINE# #INDENT# 'NAME' : db_filename , #NEWLINE# 'ENGINE' : 'django.db.backends.sqlite3' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# django . setup ( ) #NEWLINE# #UNINDENT# management . call_command ( 'inspectdb' , interactive = False ) #NEWLINE# os . remove ( conn )