old_contents: """Load PUDL data into an SQLite database."""
  
  import logging
  from sqlite3 import Connection as SQLite3Connection
  from typing import Dict
  
  import pandas as pd
  import sqlalchemy as sa
  
  from pudl.metadata.classes import Package, Resource
  
  logger = logging.getLogger(__name__)
  
  
  def dfs_to_sqlite(
      dfs: Dict[str, pd.DataFrame],
      engine: sa.engine.Engine,
      check_foreign_keys: bool = True,
      check_types: bool = True,
      check_values: bool = True,
  ) -> None:
      """Load a dictionary of dataframes into the PUDL DB."""
      # This magic makes SQLAlchemy tell SQLite to check foreign key constraints
      # whenever we insert data into thd database, which it doesn't do by default
      @sa.event.listens_for(sa.engine.Engine, "connect")
      def _set_sqlite_pragma(dbapi_connection, connection_record):
          if isinstance(dbapi_connection, SQLite3Connection):
              cursor = dbapi_connection.cursor()
              cursor.execute(
                  f"PRAGMA foreign_keys={'ON' if check_foreign_keys else 'OFF'};")
              cursor.close()
  
      # Build a list of resources from the keysin our dataframe dictionary:
      resources = [Resource.from_id(x) for x in dfs]
      # Use that list of resources to generate a SQLAlchemy MetaData object:
      md = Package(
          name="pudl",
          resources=resources,
      ).to_sql(
          check_types=check_types,
          check_values=check_values,
      )
      # Delete any existing tables, and create them anew:
      md.drop_all(engine)
      md.create_all(engine)
  
      # Load any tables that exist in our dictionary of dataframes into the
      # corresponding table in the newly create database:
      for table in md.sorted_tables:
          logger.info(f"Loading {table.name} into PUDL SQLite DB.")
          dfs[table.name].to_sql(
              table.name,
              engine,
              if_exists="append",
              index=False,
              dtype={c.name: c.type for c in table.columns},
          )
  
new_contents: """Load PUDL data into an SQLite database."""
  
  import logging
  from sqlite3 import Connection as SQLite3Connection
  from sqlite3 import sqlite_version
  from typing import Dict
  
  import pandas as pd
  import sqlalchemy as sa
  from packaging import version
  
  from pudl.metadata.classes import Package, Resource
  
  logger = logging.getLogger(__name__)
  
  MINIMUM_SQLITE_VERSION = "3.32.0"
  
  
  def dfs_to_sqlite(
      dfs: Dict[str, pd.DataFrame],
      engine: sa.engine.Engine,
      check_foreign_keys: bool = True,
      check_types: bool = True,
      check_values: bool = True,
  ) -> None:
      """Load a dictionary of dataframes into the PUDL DB."""
      # This magic makes SQLAlchemy tell SQLite to check foreign key constraints
      # whenever we insert data into thd database, which it doesn't do by default
      @sa.event.listens_for(sa.engine.Engine, "connect")
      def _set_sqlite_pragma(dbapi_connection, connection_record):
          if isinstance(dbapi_connection, SQLite3Connection):
              cursor = dbapi_connection.cursor()
              cursor.execute(
                  f"PRAGMA foreign_keys={'ON' if check_foreign_keys else 'OFF'};")
              cursor.close()
  
      if (version.parse(sqlite_version) < version.parse(MINIMUM_SQLITE_VERSION) and check_types):
          check_types = False
          logger.warning(
              f"Found SQLite {sqlite_version} which is less than "
              f"the minimum required version {MINIMUM_SQLITE_VERSION} "
              "As a result, data type constraint checking has been disabled."
          )
  
      # Build a list of resources from the keysin our dataframe dictionary:
      resources = [Resource.from_id(x) for x in dfs]
      # Use that list of resources to generate a SQLAlchemy MetaData object:
      md = Package(
          name="pudl",
          resources=resources,
      ).to_sql(
          check_types=check_types,
          check_values=check_values,
      )
      # Delete any existing tables, and create them anew:
      md.drop_all(engine)
      md.create_all(engine)
  
      # Load any tables that exist in our dictionary of dataframes into the
      # corresponding table in the newly create database:
      for table in md.sorted_tables:
          logger.info(f"Loading {table.name} into PUDL SQLite DB.")
          dfs[table.name].to_sql(
              table.name,
              engine,
              if_exists="append",
              index=False,
              dtype={c.name: c.type for c in table.columns},
          )
  
subject: Add SQLite version check to pudl.load.sqlite