Skip to content

Commit

Permalink
iterdump() workaround for compatibility with pysqlite3
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Nov 29, 2021
1 parent e02c8f3 commit c91f1e6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions sqlite_utils/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from .utils import (
file_progress,
find_spatialite,
iterdump,
sqlite3,
decode_base64_values,
progressbar,
Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions sqlite_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io
import json
import os
from sqlite3.dump import _iterdump as iterdump
from typing import cast, BinaryIO, Iterable, Optional, Tuple, Type

import click
Expand Down
3 changes: 2 additions & 1 deletion tests/test_analyze_tables.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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


Expand Down

0 comments on commit c91f1e6

Please sign in to comment.