diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fec8cfa..bbbdac9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,6 +13,11 @@ jobs: python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"] numpy: [0, 1] os: [ubuntu-latest, macos-latest, windows-latest] + include: + - os: ubuntu-latest + python-version: "3.10" + numpy: 0 + pysqlite3_sqlite_3_37: 1 steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} @@ -32,6 +37,20 @@ jobs: - name: Optionally install numpy if: matrix.numpy == 1 run: pip install numpy + - name: Optionall install pysqlite3 with SQLite 3.37 + if: matrix.pysqlite3_sqlite_3_37 == 1 + run: |- + cd /tmp + mkdir sqlite-3.37 + cd sqlite-3.37 + wget 'https://www.sqlite.org/2021/sqlite-amalgamation-3370000.zip' + unzip sqlite-amalgamation-3370000.zip + git clone https://github.com/coleifer/pysqlite3/ + cp sqlite-amalgamation-3370000/sqlite3.[ch] pysqlite3 + cd pysqlite3 + pip install wheel + python setup.py build_static build bdist_wheel + pip install /tmp/sqlite-3.37/pysqlite3/dist/*.whl - name: Run tests run: | pytest -v diff --git a/sqlite_utils/cli.py b/sqlite_utils/cli.py index cd0be82..c032bec 100644 --- a/sqlite_utils/cli.py +++ b/sqlite_utils/cli.py @@ -19,6 +19,7 @@ import tabulate from .utils import ( file_progress, find_spatialite, + iterdump, sqlite3, decode_base64_values, progressbar, @@ -326,7 +327,7 @@ def dump(path, load_extension): """Output a SQL dump of the schema and full contents of the database""" db = sqlite_utils.Database(path) _load_extensions(db, load_extension) - for line in db.conn.iterdump(): + for line in iterdump(db.conn): click.echo(line) @@ -1320,7 +1321,7 @@ def memory( return if dump: - for line in db.conn.iterdump(): + for line in iterdump(db.conn): click.echo(line) return @@ -1330,7 +1331,7 @@ def memory( if save: db2 = sqlite_utils.Database(save) - for line in db.conn.iterdump(): + for line in iterdump(db.conn): db2.execute(line) return diff --git a/sqlite_utils/utils.py b/sqlite_utils/utils.py index 00a3c02..6818831 100644 --- a/sqlite_utils/utils.py +++ b/sqlite_utils/utils.py @@ -5,6 +5,7 @@ import enum import io import json import os +from sqlite3.dump import _iterdump as iterdump # type: ignore # noqa: F401 from typing import cast, BinaryIO, Iterable, Optional, Tuple, Type import click diff --git a/tests/test_analyze_tables.py b/tests/test_analyze_tables.py index 5795a7a..2df2698 100644 --- a/tests/test_analyze_tables.py +++ b/tests/test_analyze_tables.py @@ -1,5 +1,6 @@ from sqlite_utils.db import Database, ColumnDetails from sqlite_utils import cli +from sqlite_utils.utils import iterdump from click.testing import CliRunner import pytest import sqlite3 @@ -79,7 +80,7 @@ def test_analyze_column(db_to_analyze, column, expected): def db_to_analyze_path(db_to_analyze, tmpdir): path = str(tmpdir / "test.db") db = sqlite3.connect(path) - db.executescript("\n".join(db_to_analyze.conn.iterdump())) + db.executescript("\n".join(iterdump(db_to_analyze.conn))) return path