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
Post a Comment