python - How to save output from django call_command to a variable or file -



python - How to save output from django call_command to a variable or file -

i calling commands in django within script similar to:

#!/usr/bin/python django.core.management import call_command call_command('syncdb') call_command('runserver') call_command('inspectdb')

how assign output instance call_command('inspectdb') variable or file?

i've tried

var = call_command('inspectdb')

but 'var' remains none: purpose: inspect existing tables in legacy databases not created django

you have redirect call_command's output, otherwise prints stdout returns nothing. seek saving file, reading in this:

with open('/tmp/inspectdb', 'w+') f: call_command('inspectdb', stdout=f) var = f.readlines()

python django

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -