Exemplo n.º 1
0
 def test_execute__without_transaction(self, open: Mock,
                                       update_sql: Mock) -> None:
     open.return_value = StringIO("")
     info = FileInfo("/foo/bar", "myschema", "sqlite", 45, 3)
     info.transaction = False
     apply_file("sqlite:///", info)
     open.assert_called_once_with("/foo/bar", "r")
     update_sql.assert_called_once_with("sqlite:///",
                                        "",
                                        "myschema",
                                        45,
                                        3,
                                        transaction=False)
Exemplo n.º 2
0
def parse_sql_stream(stream: Iterable[str], filename: str) -> FileInfo:
    headers = _parse_sql_headers(stream)
    try:
        schema = headers["schema"]
        dialect = headers["dialect"]
        version = _int_header(headers, "version")
        api_level = _int_header(headers, "api-level")
    except KeyError as exc:
        raise ParseError("missing header: {0.args[0]}".format(exc)) from None

    info = FileInfo(filename, schema, dialect, version, api_level)
    if "transaction" in headers:
        info.transaction = _bool_header(headers, "transaction")
    return info