code: def test_iter_sql(pokedb):
      with pokedb.connect() as conn:
          dataset = stream.iter_sql(
              query="SELECT * FROM pokemons;", conn=conn
          )
          x, y = next(dataset)
          assert x["name"] == "Bulbasaur"
          assert y is None
  
      # This raises an exception because the resource is closed...
      with pytest.raises(sql.exc.ResourceClosedError):
          for x, y in stream.iter_sql(
              query="SELECT * FROM pokemons;", conn=conn
          ):
              pass
  
      # ... and yet we can still stream over the results because SQLAlchemy prefetches them
      x, y = next(dataset)
      assert x["name"] == "Ivysaur"
  
      # The Pokedex from generation 1 contains 151 pokemons, and we've already seen 2 of them
      assert sum(1 for _ in dataset) == 149
  
      # Check that the stream is depleted
      assert sum(1 for _ in dataset) == 0
  
file_path: river/river/stream/test_sql.py
imports: from __future__ import annotations
  import json
  import os
  import zipfile
  import pytest
  import sqlalchemy
  from river import stream
label_desc: Use image node_id 2 for calling a global function with example usage: test_iter_sql(pokedb) without return types