Developers' Forum

preparation SQL queries

Re: preparation SQL queries

by Richard Lobb -
Number of replies: 0

That's odd: there's no output there from the new added line, which should come well before the exception. Are you quite sure the change was saved correctly?

Here's a more drastic change to the template which should prevent the exception and simply display the state of the working directory and the command being run for each test case. Replace everything in the template from the 'for TEST in TESTCASES' line onwards (inclusive) with the following and tell me what you get:

{% for TEST in TESTCASES %}
shutil.copyfile(db_files[0], db_working)  # Copy clean writeable db file
print("Testing with working dir files:", os.listdir())
testcode = """{{ TEST.testcode | e('py') }}"""
extra = """{{ TEST.extra | e('py') }}"""
code_to_run = '\n'.join([prelude, extra, student_answer, testcode])
with open('commands', 'w') as sqlite_commands:

with open('commands') as cmd_input:
    text_input =
        #output = subprocess.check_output(['sqlite3', db_working], input=text_input,
        #         universal_newlines=True)
        output = "Command: " + text_input
    except Exception as e:
        raise Exception("sqlite3 error: " + str(e))

{% if not loop.last %}
{% endif %}
{% endfor %}