From 14084d4c8a1c327bb227d3eff4470d1d32600da5 Mon Sep 17 00:00:00 2001 From: Daniel Roy Greenfeld Date: Tue, 10 Dec 2024 15:05:46 +0000 Subject: [PATCH] Convert to use apswutils --- fastlite/core.py | 4 +- fastlite/kw.py | 3 +- nbs/00_core.ipynb | 487 +++++++++++++++++++++++------------------- nbs/index.ipynb | 452 ++++----------------------------------- nbs/test_insert.ipynb | 86 ++++---- nbs/test_update.ipynb | 14 +- nbs/test_upsert.ipynb | 14 +- settings.ini | 2 +- 8 files changed, 359 insertions(+), 703 deletions(-) diff --git a/fastlite/core.py b/fastlite/core.py index 79b6fe9..88f3ad5 100644 --- a/fastlite/core.py +++ b/fastlite/core.py @@ -14,8 +14,8 @@ from fastcore.utils import * from fastcore.xml import highlight from fastcore.xtras import hl_md, dataclass_src -from sqlite_minutils.db import * -from sqlite_minutils.utils import rows_from_file,TypeTracker,Format +from apswutils.db import * +from apswutils.utils import rows_from_file,TypeTracker,Format import types try: from graphviz import Source diff --git a/fastlite/kw.py b/fastlite/kw.py index 9ea41e7..cd2d027 100644 --- a/fastlite/kw.py +++ b/fastlite/kw.py @@ -1,7 +1,8 @@ from dataclasses import MISSING from typing import Any,Union,Tuple,List,Iterable from fastcore.utils import * -from sqlite_minutils.db import Database,Table,DEFAULT,ForeignKeysType,Default,Queryable,NotFoundError +from apswutils.db import Database,Table,DEFAULT,ForeignKeysType,Default,Queryable,NotFoundError +from apsw import SQLError from enum import Enum class MissingPrimaryKey(Exception): pass diff --git a/nbs/00_core.ipynb b/nbs/00_core.ipynb index a96859e..34c3825 100644 --- a/nbs/00_core.ipynb +++ b/nbs/00_core.ipynb @@ -40,8 +40,8 @@ "from fastcore.utils import *\n", "from fastcore.xml import highlight\n", "from fastcore.xtras import hl_md, dataclass_src\n", - "from sqlite_minutils.db import *\n", - "from sqlite_minutils.utils import rows_from_file,TypeTracker,Format\n", + "from apswutils.db import *\n", + "from apswutils.utils import rows_from_file,TypeTracker,Format\n", "import types\n", "\n", "try: from graphviz import Source\n", @@ -74,7 +74,15 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "WARNING:root:SQLITE_LOG: recovered 44 frames from WAL file /Users/drg/answer/fastlite/nbs/chinook.sqlite-wal (283) SQLITE_NOTICE_RECOVER_WAL\n" + ] + } + ], "source": [ "db = Database(\"chinook.sqlite\")" ] @@ -121,7 +129,7 @@ { "data": { "text/plain": [ - "Album, Artist, Customer, Employee, Genre, Invoice, InvoiceLine, MediaType, Playlist, PlaylistTrack, Track, cat" + "Album, Artist, Customer, Employee, Genre, Invoice, InvoiceLine, MediaType, Playlist, PlaylistTrack, Track, sqlite_stat1, sqlite_stat4" ] }, "execution_count": null, @@ -690,7 +698,7 @@ { "data": { "text/plain": [ - ">" + ">" ] }, "execution_count": null, @@ -1001,7 +1009,8 @@ "CREATE TABLE [cat] (\n", " [id] INTEGER PRIMARY KEY,\n", " [name] TEXT,\n", - " [weight] FLOAT\n", + " [age] INTEGER,\n", + " [city] TEXT\n", ")\n" ] } @@ -1018,7 +1027,7 @@ { "data": { "text/plain": [ - "" + "
" ] }, "execution_count": null, @@ -1045,7 +1054,7 @@ { "data": { "text/plain": [ - "
" + "
" ] }, "execution_count": null, @@ -1088,10 +1097,12 @@ "name": "stdout", "output_type": "stream", "text": [ - "CREATE TABLE [cat] (\n", + "CREATE TABLE \"cat\" (\n", " [id] INTEGER PRIMARY KEY,\n", " [name] TEXT,\n", - " [weight] FLOAT\n", + " [age] INTEGER,\n", + " [city] TEXT,\n", + " [breed] TEXT\n", ")\n" ] } @@ -1283,307 +1294,341 @@ "\n", "\n", - "\n", "\n", - "\n", - "\n", + "\n", + "\n", "G\n", - "\n", + "\n", "\n", "\n", "Album\n", - "\n", - "\n", - "Album\n", - "\n", - "\n", - "AlbumId 🔑\n", - "\n", - "Title\n", - "\n", - "ArtistId\n", - "\n", + "\n", + "\n", + "Album\n", + "\n", + "\n", + "AlbumId 🔑\n", + "\n", + "Title\n", + "\n", + "ArtistId\n", + "\n", "\n", "\n", "\n", "Artist\n", - "\n", - "\n", - "Artist\n", - "\n", - "\n", - "ArtistId 🔑\n", - "\n", - "Name\n", - "\n", + "\n", + "\n", + "Artist\n", + "\n", + "\n", + "ArtistId 🔑\n", + "\n", + "Name\n", + "\n", "\n", "\n", "\n", "Album:ArtistId->Artist:ArtistId\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "Customer\n", - "\n", - "\n", - "Customer\n", - "\n", - "\n", - "CustomerId 🔑\n", - "\n", - "FirstName\n", - "\n", - "LastName\n", - "\n", - "Company\n", - "\n", - "Address\n", - "\n", - "City\n", - "\n", - "State\n", - "\n", - "Country\n", - "\n", - "PostalCode\n", - "\n", - "Phone\n", - "\n", - "Fax\n", - "\n", - "Email\n", - "\n", - "SupportRepId\n", - "\n", + "\n", + "\n", + "Customer\n", + "\n", + "\n", + "CustomerId 🔑\n", + "\n", + "FirstName\n", + "\n", + "LastName\n", + "\n", + "Company\n", + "\n", + "Address\n", + "\n", + "City\n", + "\n", + "State\n", + "\n", + "Country\n", + "\n", + "PostalCode\n", + "\n", + "Phone\n", + "\n", + "Fax\n", + "\n", + "Email\n", + "\n", + "SupportRepId\n", + "\n", "\n", "\n", "\n", "Employee\n", - "\n", - "\n", - "Employee\n", - "\n", - "\n", - "EmployeeId 🔑\n", - "\n", - "LastName\n", - "\n", - "FirstName\n", - "\n", - "Title\n", - "\n", - "ReportsTo\n", - "\n", - "BirthDate\n", - "\n", - "HireDate\n", - "\n", - "Address\n", - "\n", - "City\n", - "\n", - "State\n", - "\n", - "Country\n", - "\n", - "PostalCode\n", - "\n", - "Phone\n", - "\n", - "Fax\n", - "\n", - "Email\n", - "\n", + "\n", + "\n", + "Employee\n", + "\n", + "\n", + "EmployeeId 🔑\n", + "\n", + "LastName\n", + "\n", + "FirstName\n", + "\n", + "Title\n", + "\n", + "ReportsTo\n", + "\n", + "BirthDate\n", + "\n", + "HireDate\n", + "\n", + "Address\n", + "\n", + "City\n", + "\n", + "State\n", + "\n", + "Country\n", + "\n", + "PostalCode\n", + "\n", + "Phone\n", + "\n", + "Fax\n", + "\n", + "Email\n", + "\n", "\n", "\n", "\n", "Customer:SupportRepId->Employee:EmployeeId\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "Employee:ReportsTo->Employee:EmployeeId\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "Genre\n", - "\n", - "\n", - "Genre\n", - "\n", - "\n", - "GenreId 🔑\n", - "\n", - "Name\n", - "\n", + "\n", + "\n", + "Genre\n", + "\n", + "\n", + "GenreId 🔑\n", + "\n", + "Name\n", + "\n", "\n", "\n", "\n", "Invoice\n", - "\n", - "\n", - "Invoice\n", - "\n", - "\n", - "InvoiceId 🔑\n", - "\n", - "CustomerId\n", - "\n", - "InvoiceDate\n", - "\n", - "BillingAddress\n", - "\n", - "BillingCity\n", - "\n", - "BillingState\n", - "\n", - "BillingCountry\n", - "\n", - "BillingPostalCode\n", - "\n", - "Total\n", - "\n", + "\n", + "\n", + "Invoice\n", + "\n", + "\n", + "InvoiceId 🔑\n", + "\n", + "CustomerId\n", + "\n", + "InvoiceDate\n", + "\n", + "BillingAddress\n", + "\n", + "BillingCity\n", + "\n", + "BillingState\n", + "\n", + "BillingCountry\n", + "\n", + "BillingPostalCode\n", + "\n", + "Total\n", + "\n", "\n", "\n", "\n", "Invoice:CustomerId->Customer:CustomerId\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "InvoiceLine\n", - "\n", - "\n", - "InvoiceLine\n", - "\n", - "\n", - "InvoiceLineId 🔑\n", - "\n", - "InvoiceId\n", - "\n", - "TrackId\n", - "\n", - "UnitPrice\n", - "\n", - "Quantity\n", - "\n", + "\n", + "\n", + "InvoiceLine\n", + "\n", + "\n", + "InvoiceLineId 🔑\n", + "\n", + "InvoiceId\n", + "\n", + "TrackId\n", + "\n", + "UnitPrice\n", + "\n", + "Quantity\n", + "\n", "\n", "\n", "\n", "InvoiceLine:InvoiceId->Invoice:InvoiceId\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "Track\n", - "\n", - "\n", - "Track\n", - "\n", - "\n", - "TrackId 🔑\n", - "\n", - "Name\n", - "\n", - "AlbumId\n", - "\n", - "MediaTypeId\n", - "\n", - "GenreId\n", - "\n", - "Composer\n", - "\n", - "Milliseconds\n", - "\n", - "Bytes\n", - "\n", - "UnitPrice\n", - "\n", + "\n", + "\n", + "Track\n", + "\n", + "\n", + "TrackId 🔑\n", + "\n", + "Name\n", + "\n", + "AlbumId\n", + "\n", + "MediaTypeId\n", + "\n", + "GenreId\n", + "\n", + "Composer\n", + "\n", + "Milliseconds\n", + "\n", + "Bytes\n", + "\n", + "UnitPrice\n", + "\n", "\n", "\n", "\n", "InvoiceLine:TrackId->Track:TrackId\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "MediaType\n", - "\n", - "\n", - "MediaType\n", - "\n", - "\n", - "MediaTypeId 🔑\n", - "\n", - "Name\n", - "\n", + "\n", + "\n", + "MediaType\n", + "\n", + "\n", + "MediaTypeId 🔑\n", + "\n", + "Name\n", + "\n", "\n", "\n", "\n", "Playlist\n", - "\n", - "\n", - "Playlist\n", - "\n", - "\n", - "PlaylistId 🔑\n", - "\n", - "Name\n", - "\n", + "\n", + "\n", + "Playlist\n", + "\n", + "\n", + "PlaylistId 🔑\n", + "\n", + "Name\n", + "\n", "\n", "\n", "\n", "PlaylistTrack\n", - "\n", - "\n", - "PlaylistTrack\n", - "\n", - "\n", - "PlaylistId 🔑\n", - "\n", - "\n", - "TrackId 🔑\n", - "\n", + "\n", + "\n", + "PlaylistTrack\n", + "\n", + "\n", + "PlaylistId 🔑\n", + "\n", + "\n", + "TrackId 🔑\n", + "\n", "\n", "\n", "\n", "PlaylistTrack:PlaylistId->Playlist:PlaylistId\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "PlaylistTrack:TrackId->Track:TrackId\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "Track:AlbumId->Album:AlbumId\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "Track:GenreId->Genre:GenreId\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "Track:MediaTypeId->MediaType:MediaTypeId\n", - "\n", - "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "sqlite_stat1\n", + "\n", + "\n", + "sqlite_stat1\n", + "\n", + "tbl\n", + "\n", + "idx\n", + "\n", + "stat\n", + "\n", + "\n", + "\n", + "\n", + "sqlite_stat4\n", + "\n", + "\n", + "sqlite_stat4\n", + "\n", + "tbl\n", + "\n", + "idx\n", + "\n", + "neq\n", + "\n", + "nlt\n", + "\n", + "ndlt\n", + "\n", + "sample\n", + "\n", "\n", "\n", "\n" diff --git a/nbs/index.ipynb b/nbs/index.ipynb index da5b605..67e4573 100644 --- a/nbs/index.ipynb +++ b/nbs/index.ipynb @@ -109,7 +109,7 @@ { "data": { "text/plain": [ - "Album, Artist, Customer, Employee, Genre, Invoice, InvoiceLine, MediaType, Playlist, PlaylistTrack, Track" + "Album, Artist, Customer, Employee, Genre, Invoice, InvoiceLine, MediaType, Playlist, PlaylistTrack, Track, sqlite_stat1, sqlite_stat4" ] }, "execution_count": null, @@ -1219,7 +1219,8 @@ "\n", "### Database.import_file\n", "\n", - "> Database.import_file (table_name, file, format=None, pk=None)\n", + "> Database.import_file (table_name, file, format=None, pk=None,\n", + "> alter=False)\n", "\n", "*Import path or handle `file` to new table `table_name`*" ], @@ -1230,7 +1231,8 @@ "\n", "### Database.import_file\n", "\n", - "> Database.import_file (table_name, file, format=None, pk=None)\n", + "> Database.import_file (table_name, file, format=None, pk=None,\n", + "> alter=False)\n", "\n", "*Import path or handle `file` to new table `table_name`*" ] @@ -1305,322 +1307,27 @@ "\n", "\n", - "\n", "\n", - "\n", - "\n", + "\n", + "\n", "G\n", - "\n", - "\n", + "\n", + "\n", "\n", - "Album\n", - "\n", - "\n", - "Album\n", - "\n", - "\n", - "AlbumId 🔑\n", - "\n", - "Title\n", - "\n", - "ArtistId\n", - "\n", - "\n", - "\n", - "\n", - "Artist\n", - "\n", - "\n", - "Artist\n", - "\n", - "\n", - "ArtistId 🔑\n", - "\n", - "Name\n", - "\n", - "\n", - "\n", - "\n", - "Album:ArtistId->Artist:ArtistId\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "Customer\n", - "\n", - "\n", - "Customer\n", - "\n", - "\n", - "CustomerId 🔑\n", - "\n", - "FirstName\n", - "\n", - "LastName\n", - "\n", - "Company\n", - "\n", - "Address\n", - "\n", - "City\n", - "\n", - "State\n", - "\n", - "Country\n", - "\n", - "PostalCode\n", - "\n", - "Phone\n", - "\n", - "Fax\n", - "\n", - "Email\n", - "\n", - "SupportRepId\n", - "\n", - "\n", - "\n", - "\n", - "Employee\n", - "\n", - "\n", - "Employee\n", - "\n", - "\n", - "EmployeeId 🔑\n", - "\n", - "LastName\n", - "\n", - "FirstName\n", - "\n", - "Title\n", - "\n", - "ReportsTo\n", - "\n", - "BirthDate\n", - "\n", - "HireDate\n", - "\n", - "Address\n", - "\n", - "City\n", - "\n", - "State\n", - "\n", - "Country\n", - "\n", - "PostalCode\n", - "\n", - "Phone\n", - "\n", - "Fax\n", - "\n", - "Email\n", - "\n", - "\n", - "\n", - "\n", - "Customer:SupportRepId->Employee:EmployeeId\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "Employee:ReportsTo->Employee:EmployeeId\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "Genre\n", - "\n", - "\n", - "Genre\n", - "\n", - "\n", - "GenreId 🔑\n", - "\n", - "Name\n", - "\n", - "\n", - "\n", - "\n", - "Invoice\n", - "\n", - "\n", - "Invoice\n", - "\n", - "\n", - "InvoiceId 🔑\n", - "\n", - "CustomerId\n", - "\n", - "InvoiceDate\n", - "\n", - "BillingAddress\n", - "\n", - "BillingCity\n", - "\n", - "BillingState\n", - "\n", - "BillingCountry\n", - "\n", - "BillingPostalCode\n", - "\n", - "Total\n", - "\n", - "\n", - "\n", - "\n", - "Invoice:CustomerId->Customer:CustomerId\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "InvoiceLine\n", - "\n", - "\n", - "InvoiceLine\n", - "\n", - "\n", - "InvoiceLineId 🔑\n", - "\n", - "InvoiceId\n", - "\n", - "TrackId\n", - "\n", - "UnitPrice\n", - "\n", - "Quantity\n", - "\n", - "\n", - "\n", - "\n", - "InvoiceLine:InvoiceId->Invoice:InvoiceId\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "Track\n", - "\n", - "\n", - "Track\n", - "\n", - "\n", - "TrackId 🔑\n", - "\n", - "Name\n", - "\n", - "AlbumId\n", - "\n", - "MediaTypeId\n", - "\n", - "GenreId\n", - "\n", - "Composer\n", - "\n", - "Milliseconds\n", - "\n", - "Bytes\n", - "\n", - "UnitPrice\n", - "\n", - "\n", - "\n", - "\n", - "InvoiceLine:TrackId->Track:TrackId\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "MediaType\n", - "\n", - "\n", - "MediaType\n", - "\n", - "\n", - "MediaTypeId 🔑\n", - "\n", - "Name\n", - "\n", - "\n", - "\n", - "\n", - "Playlist\n", - "\n", - "\n", - "Playlist\n", - "\n", - "\n", - "PlaylistId 🔑\n", - "\n", - "Name\n", - "\n", - "\n", - "\n", - "\n", - "PlaylistTrack\n", - "\n", - "\n", - "PlaylistTrack\n", - "\n", - "\n", - "PlaylistId 🔑\n", - "\n", - "\n", - "TrackId 🔑\n", - "\n", - "\n", - "\n", - "\n", - "PlaylistTrack:PlaylistId->Playlist:PlaylistId\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "PlaylistTrack:TrackId->Track:TrackId\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "Track:AlbumId->Album:AlbumId\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "Track:GenreId->Genre:GenreId\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "Track:MediaTypeId->MediaType:MediaTypeId\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "cat\n", - "\n", - "\n", - "cat\n", - "\n", - "\n", - "id 🔑\n", - "\n", - "name\n", - "\n", - "weight\n", - "\n", + "people\n", + "\n", + "\n", + "people\n", + "\n", + "id\n", + "\n", + "name\n", + "\n", + "age\n", + "\n", "\n", "\n", "\n" @@ -1656,118 +1363,53 @@ "\n", "\n", - "\n", "\n", - "\n", - "\n", + "\n", + "\n", "G\n", - "\n", + "\n", "\n", "\n", "Artist\n", - "\n", - "\n", - "Artist\n", - "\n", - "\n", - "ArtistId 🔑\n", - "\n", - "Name\n", - "\n", + "\n", + "\n", + "Artist\n", + "\n", "\n", "\n", "\n", "Album\n", - "\n", - "\n", - "Album\n", - "\n", - "\n", - "AlbumId 🔑\n", - "\n", - "Title\n", - "\n", - "ArtistId\n", - "\n", - "\n", - "\n", - "\n", - "Album:ArtistId->Artist:ArtistId\n", - "\n", - "\n", + "\n", + "\n", + "Album\n", + "\n", "\n", "\n", "\n", "Track\n", - "\n", - "\n", - "Track\n", - "\n", - "\n", - "TrackId 🔑\n", - "\n", - "Name\n", - "\n", - "AlbumId\n", - "\n", - "MediaTypeId\n", - "\n", - "GenreId\n", - "\n", - "Composer\n", - "\n", - "Milliseconds\n", - "\n", - "Bytes\n", - "\n", - "UnitPrice\n", - "\n", - "\n", - "\n", - "\n", - "Track:AlbumId->Album:AlbumId\n", - "\n", - "\n", + "\n", + "\n", + "Track\n", + "\n", "\n", "\n", "\n", "Genre\n", - "\n", - "\n", - "Genre\n", - "\n", - "\n", - "GenreId 🔑\n", - "\n", - "Name\n", - "\n", - "\n", - "\n", - "\n", - "Track:GenreId->Genre:GenreId\n", - "\n", - "\n", + "\n", + "\n", + "Genre\n", + "\n", "\n", "\n", "\n", "MediaType\n", - "\n", - "\n", - "MediaType\n", - "\n", - "\n", - "MediaTypeId 🔑\n", - "\n", - "Name\n", - "\n", - "\n", - "\n", - "\n", - "Track:MediaTypeId->MediaType:MediaTypeId\n", - "\n", - "\n", + "\n", + "\n", + "MediaType\n", + "\n", "\n", "\n", "\n" diff --git a/nbs/test_insert.ipynb b/nbs/test_insert.ipynb index 19f6f6b..e014fbd 100644 --- a/nbs/test_insert.ipynb +++ b/nbs/test_insert.ipynb @@ -18,7 +18,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "ad470f25", "metadata": {}, "outputs": [], @@ -36,7 +36,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "97dd1b48", "metadata": {}, "outputs": [], @@ -46,7 +46,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "5102a3ac", "metadata": {}, "outputs": [], @@ -56,7 +56,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "id": "9188c149", "metadata": {}, "outputs": [], @@ -98,7 +98,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "id": "fba0c4f7", "metadata": {}, "outputs": [ @@ -108,7 +108,7 @@ "{}" ] }, - "execution_count": 5, + "execution_count": null, "metadata": {}, "output_type": "execute_result" } @@ -127,7 +127,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "id": "ace59c88", "metadata": {}, "outputs": [], @@ -147,7 +147,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "id": "a93ec70a", "metadata": {}, "outputs": [], @@ -159,7 +159,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "id": "79cd5186", "metadata": {}, "outputs": [], @@ -173,7 +173,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "id": "aa988175", "metadata": {}, "outputs": [], @@ -203,7 +203,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "id": "1fdd0aaf", "metadata": {}, "outputs": [], @@ -221,7 +221,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "id": "c736aa0f", "metadata": {}, "outputs": [], @@ -239,7 +239,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "id": "cfd90ab0", "metadata": {}, "outputs": [], @@ -261,7 +261,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "id": "72a25f8d", "metadata": {}, "outputs": [], @@ -300,7 +300,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": null, "id": "5a968d13", "metadata": {}, "outputs": [], @@ -319,7 +319,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": null, "id": "92d53608", "metadata": {}, "outputs": [], @@ -330,7 +330,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": null, "id": "51cb29b1", "metadata": {}, "outputs": [], @@ -368,7 +368,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": null, "id": "972bab86", "metadata": {}, "outputs": [], @@ -387,7 +387,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": null, "id": "55364dd6", "metadata": {}, "outputs": [], @@ -407,7 +407,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": null, "id": "45a4c2aa", "metadata": {}, "outputs": [], @@ -420,12 +420,12 @@ "id": "f1209e4b", "metadata": {}, "source": [ - "Test that extra fields raise `sqlite3.OperationalError`" + "Test that extra fields raise `apsw.SqlError`" ] }, { "cell_type": "code", - "execution_count": 20, + "execution_count": null, "id": "07c034e9", "metadata": {}, "outputs": [], @@ -435,14 +435,14 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": null, "id": "963008b6", "metadata": {}, "outputs": [], "source": [ "try:\n", " p = people.insert(name='Extra', age=25, title='Dr')\n", - "except OperationalError as e:\n", + "except SQLError as e:\n", " assert e.args[0] == 'table people has no column named age'" ] }, @@ -480,7 +480,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": null, "id": "c8a95079", "metadata": {}, "outputs": [], @@ -500,7 +500,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": null, "id": "cee37620", "metadata": {}, "outputs": [], @@ -522,7 +522,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": null, "id": "98118662", "metadata": {}, "outputs": [], @@ -551,7 +551,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": null, "id": "96632dfb", "metadata": {}, "outputs": [], @@ -571,7 +571,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": null, "id": "b110b0a7", "metadata": {}, "outputs": [], @@ -592,7 +592,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": null, "id": "803e6bc9", "metadata": {}, "outputs": [], @@ -614,7 +614,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": null, "id": "570d5dce", "metadata": {}, "outputs": [], @@ -645,7 +645,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": null, "id": "ca76eb12", "metadata": {}, "outputs": [], @@ -671,7 +671,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": null, "id": "5a37e482", "metadata": {}, "outputs": [], @@ -696,7 +696,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": null, "id": "da81a215", "metadata": {}, "outputs": [], @@ -721,35 +721,23 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": null, "id": "9d7d7991", "metadata": {}, "outputs": [], "source": [ "try:\n", " people.insert_all([{'name': 'Valid'}, {'invalid_col': 'Bad'}])\n", - "except OperationalError as e:\n", + "except SQLError as e:\n", " assert 'no column named invalid_col' in str(e)" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "python3", "language": "python", "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.12.6" } }, "nbformat": 4, diff --git a/nbs/test_update.ipynb b/nbs/test_update.ipynb index f1cd230..791907f 100644 --- a/nbs/test_update.ipynb +++ b/nbs/test_update.ipynb @@ -373,17 +373,7 @@ "id": "f1209e4b", "metadata": {}, "source": [ - "Test that extra fields raise `sqlite3.OperationalError`" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "07c034e9", - "metadata": {}, - "outputs": [], - "source": [ - "from sqlite3 import OperationalError" + "Test that extra fields raise `fastlite.SqlError`, which is a shim for `apsw.SqlError`:" ] }, { @@ -395,7 +385,7 @@ "source": [ "try:\n", " p = people.update(dict(id=person.id, name='Extra', age=25, title='Dr'))\n", - "except OperationalError as e:\n", + "except SQLError as e:\n", " assert e.args[0] == 'no such column: age'" ] } diff --git a/nbs/test_upsert.ipynb b/nbs/test_upsert.ipynb index e1d2326..a4211e6 100644 --- a/nbs/test_upsert.ipynb +++ b/nbs/test_upsert.ipynb @@ -428,17 +428,7 @@ "id": "f1209e4b", "metadata": {}, "source": [ - "Test that extra fields raise `sqlite3.OperationalError`" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "07c034e9", - "metadata": {}, - "outputs": [], - "source": [ - "from sqlite3 import OperationalError" + "Test that extra fields raise `fastlite.SqlError`" ] }, { @@ -450,7 +440,7 @@ "source": [ "try:\n", " p = people.upsert(dict(name='Extra', age=25, title='Dr', id=person.id))\n", - "except OperationalError as e:\n", + "except SQLError as e:\n", " assert e.args[0] == 'no such column: age'" ] } diff --git a/settings.ini b/settings.ini index d071661..08980d2 100644 --- a/settings.ini +++ b/settings.ini @@ -5,7 +5,7 @@ version = 0.0.14 min_python = 3.10 license = apache2 black_formatting = False -requirements = fastcore>=1.7.1 sqlite-minutils>=3.37.0.post4 +requirements = fastcore>=1.7.1 apswutils conda_user = fastai doc_path = _docs lib_path = fastlite