mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-27 04:14:30 +02:00
Merge branch 'simonw:main' into main
This commit is contained in:
commit
61de8d997d
7 changed files with 46 additions and 44 deletions
14
.github/workflows/publish.yml
vendored
14
.github/workflows/publish.yml
vendored
|
|
@ -9,15 +9,15 @@ jobs:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
|
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
- uses: actions/cache@v3
|
- uses: actions/cache@v4
|
||||||
name: Configure pip caching
|
name: Configure pip caching
|
||||||
with:
|
with:
|
||||||
path: ~/.cache/pip
|
path: ~/.cache/pip
|
||||||
|
|
@ -34,12 +34,12 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [test]
|
needs: [test]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: '3.12'
|
python-version: '3.12'
|
||||||
- uses: actions/cache@v3
|
- uses: actions/cache@v4
|
||||||
name: Configure pip caching
|
name: Configure pip caching
|
||||||
with:
|
with:
|
||||||
path: ~/.cache/pip
|
path: ~/.cache/pip
|
||||||
|
|
|
||||||
10
.github/workflows/spellcheck.yml
vendored
10
.github/workflows/spellcheck.yml
vendored
|
|
@ -6,12 +6,12 @@ jobs:
|
||||||
spellcheck:
|
spellcheck:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: 3.9
|
python-version: "3.12"
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v4
|
||||||
name: Configure pip caching
|
name: Configure pip caching
|
||||||
with:
|
with:
|
||||||
path: ~/.cache/pip
|
path: ~/.cache/pip
|
||||||
|
|
|
||||||
8
.github/workflows/test-coverage.yml
vendored
8
.github/workflows/test-coverage.yml
vendored
|
|
@ -12,12 +12,12 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Check out repo
|
- name: Check out repo
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v4
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: 3.9
|
python-version: "3.11"
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v4
|
||||||
name: Configure pip caching
|
name: Configure pip caching
|
||||||
with:
|
with:
|
||||||
path: ~/.cache/pip
|
path: ~/.cache/pip
|
||||||
|
|
|
||||||
23
.github/workflows/test.yml
vendored
23
.github/workflows/test.yml
vendored
|
|
@ -10,16 +10,22 @@ jobs:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
|
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
||||||
numpy: [0, 1]
|
numpy: [0, 1]
|
||||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
os: [ubuntu-latest, macos-latest, windows-latest, macos-14]
|
||||||
|
# Skip 3.8 and 3.9 on macos-14 - it only has 3.10+
|
||||||
|
exclude:
|
||||||
|
- python-version: "3.8"
|
||||||
|
os: macos-14
|
||||||
|
- python-version: "3.9"
|
||||||
|
os: macos-14
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
- uses: actions/cache@v3
|
- uses: actions/cache@v4
|
||||||
name: Configure pip caching
|
name: Configure pip caching
|
||||||
with:
|
with:
|
||||||
path: ~/.cache/pip
|
path: ~/.cache/pip
|
||||||
|
|
@ -29,8 +35,7 @@ jobs:
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
pip install -e '.[test,mypy,flake8]'
|
pip install -e '.[test,mypy,flake8]'
|
||||||
- name: Optionally install tui dependencies (not 3.7)
|
- name: Optionally install tui dependencies
|
||||||
if: matrix.python-version != '3.7'
|
|
||||||
run: pip install -e '.[tui]'
|
run: pip install -e '.[tui]'
|
||||||
- name: Optionally install numpy
|
- name: Optionally install numpy
|
||||||
if: matrix.numpy == 1
|
if: matrix.numpy == 1
|
||||||
|
|
@ -50,12 +55,10 @@ jobs:
|
||||||
pytest -v
|
pytest -v
|
||||||
- name: run mypy
|
- name: run mypy
|
||||||
run: mypy sqlite_utils tests
|
run: mypy sqlite_utils tests
|
||||||
- name: run flake8 if Python 3.8 or higher
|
- name: run flake8
|
||||||
if: matrix.python-version >= 3.8
|
|
||||||
run: flake8
|
run: flake8
|
||||||
- name: Check formatting
|
- name: Check formatting
|
||||||
run: black . --check
|
run: black . --check
|
||||||
- name: Check if cog needs to be run
|
- name: Check if cog needs to be run
|
||||||
if: matrix.python-version != '3.7'
|
|
||||||
run: |
|
run: |
|
||||||
cog --check README.md docs/*.rst
|
cog --check README.md docs/*.rst
|
||||||
|
|
|
||||||
5
setup.py
5
setup.py
|
|
@ -32,7 +32,7 @@ setup(
|
||||||
"pluggy",
|
"pluggy",
|
||||||
],
|
],
|
||||||
extras_require={
|
extras_require={
|
||||||
"test": ["pytest", "black", "hypothesis", "cogapp"],
|
"test": ["pytest", "black>=24.1.1", "hypothesis", "cogapp"],
|
||||||
"docs": [
|
"docs": [
|
||||||
"furo",
|
"furo",
|
||||||
"sphinx-autobuild",
|
"sphinx-autobuild",
|
||||||
|
|
@ -64,7 +64,7 @@ setup(
|
||||||
"Issues": "https://github.com/simonw/sqlite-utils/issues",
|
"Issues": "https://github.com/simonw/sqlite-utils/issues",
|
||||||
"CI": "https://github.com/simonw/sqlite-utils/actions",
|
"CI": "https://github.com/simonw/sqlite-utils/actions",
|
||||||
},
|
},
|
||||||
python_requires=">=3.7",
|
python_requires=">=3.8",
|
||||||
classifiers=[
|
classifiers=[
|
||||||
"Development Status :: 5 - Production/Stable",
|
"Development Status :: 5 - Production/Stable",
|
||||||
"Intended Audience :: Developers",
|
"Intended Audience :: Developers",
|
||||||
|
|
@ -72,7 +72,6 @@ setup(
|
||||||
"Intended Audience :: End Users/Desktop",
|
"Intended Audience :: End Users/Desktop",
|
||||||
"Topic :: Database",
|
"Topic :: Database",
|
||||||
"License :: OSI Approved :: Apache Software License",
|
"License :: OSI Approved :: Apache Software License",
|
||||||
"Programming Language :: Python :: 3.7",
|
|
||||||
"Programming Language :: Python :: 3.8",
|
"Programming Language :: Python :: 3.8",
|
||||||
"Programming Language :: Python :: 3.9",
|
"Programming Language :: Python :: 3.9",
|
||||||
"Programming Language :: Python :: 3.10",
|
"Programming Language :: Python :: 3.10",
|
||||||
|
|
|
||||||
|
|
@ -457,8 +457,7 @@ class Database:
|
||||||
fn_name, arity, fn, **dict(kwargs, deterministic=True)
|
fn_name, arity, fn, **dict(kwargs, deterministic=True)
|
||||||
)
|
)
|
||||||
registered = True
|
registered = True
|
||||||
except (sqlite3.NotSupportedError, TypeError):
|
except sqlite3.NotSupportedError:
|
||||||
# TypeError is Python 3.7 "function takes at most 3 arguments"
|
|
||||||
pass
|
pass
|
||||||
if not registered:
|
if not registered:
|
||||||
self.conn.create_function(fn_name, arity, fn, **kwargs)
|
self.conn.create_function(fn_name, arity, fn, **kwargs)
|
||||||
|
|
@ -951,9 +950,9 @@ class Database:
|
||||||
" [{column_name}] {column_type}{column_extras}".format(
|
" [{column_name}] {column_type}{column_extras}".format(
|
||||||
column_name=column_name,
|
column_name=column_name,
|
||||||
column_type=COLUMN_TYPE_MAPPING[column_type],
|
column_type=COLUMN_TYPE_MAPPING[column_type],
|
||||||
column_extras=(" " + " ".join(column_extras))
|
column_extras=(
|
||||||
if column_extras
|
(" " + " ".join(column_extras)) if column_extras else ""
|
||||||
else "",
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
extra_pk = ""
|
extra_pk = ""
|
||||||
|
|
@ -1527,9 +1526,11 @@ class Table(Queryable):
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return "<Table {}{}>".format(
|
return "<Table {}{}>".format(
|
||||||
self.name,
|
self.name,
|
||||||
" (does not exist yet)"
|
(
|
||||||
if not self.exists()
|
" (does not exist yet)"
|
||||||
else " ({})".format(", ".join(c.name for c in self.columns)),
|
if not self.exists()
|
||||||
|
else " ({})".format(", ".join(c.name for c in self.columns))
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
@ -3001,9 +3002,11 @@ class Table(Queryable):
|
||||||
value = jsonify_if_needed(
|
value = jsonify_if_needed(
|
||||||
record.get(
|
record.get(
|
||||||
key,
|
key,
|
||||||
None
|
(
|
||||||
if key != hash_id
|
None
|
||||||
else hash_record(record, hash_id_columns),
|
if key != hash_id
|
||||||
|
else hash_record(record, hash_id_columns)
|
||||||
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if key in extracts:
|
if key in extracts:
|
||||||
|
|
|
||||||
|
|
@ -304,10 +304,7 @@ def rows_from_file(
|
||||||
rows = rows_from_file(
|
rows = rows_from_file(
|
||||||
fp, format=Format.CSV, dialect=csv.excel_tab, encoding=encoding
|
fp, format=Format.CSV, dialect=csv.excel_tab, encoding=encoding
|
||||||
)[0]
|
)[0]
|
||||||
return (
|
return _extra_key_strategy(rows, ignore_extras, extras_key), Format.TSV
|
||||||
_extra_key_strategy(rows, ignore_extras, extras_key),
|
|
||||||
Format.TSV,
|
|
||||||
)
|
|
||||||
elif format is None:
|
elif format is None:
|
||||||
# Detect the format, then call this recursively
|
# Detect the format, then call this recursively
|
||||||
buffered = io.BufferedReader(cast(io.RawIOBase, fp), buffer_size=4096)
|
buffered = io.BufferedReader(cast(io.RawIOBase, fp), buffer_size=4096)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue