diff --git a/mo_sqlite/transacfion.py b/mo_sqlite/transacfion.py index c114a24..3a639f2 100644 --- a/mo_sqlite/transacfion.py +++ b/mo_sqlite/transacfion.py @@ -8,6 +8,7 @@ # Contact: Kyle Lahnakoski (kyle@lahnakoski.com) # from dataclasses import is_dataclass, fields +from typing import Optional from mo_dots import unwraplist, Data, is_missing from mo_future import allocate_lock as _allocate_lock @@ -120,16 +121,16 @@ def table_to_list(result, *, as_dataclass): field_names = fields(as_dataclass) fields_to_index = [None] * len(field_names) for fi, f in enumerate(field_names): - for hi, h in enumerate(result.header): + for index, h in enumerate(result.header): if untype_field(h)[0] == f.name: - fields_to_index[fi] = hi + fields_to_index[fi] = index output = [] for row in result.data: obj = object.__new__(as_dataclass) obj.__dict__ = { - f.name: None if hi is None else value_to_type(row[hi], f.type) - for f, hi in zip(field_names, fields_to_index) + f.name: None if header_index is None else row[header_index] + for f, header_index in zip(field_names, fields_to_index) } output.append(obj) return output diff --git a/packaging/setup.py b/packaging/setup.py index 728b2eb..1cba54c 100644 --- a/packaging/setup.py +++ b/packaging/setup.py @@ -8,12 +8,12 @@ description='Multithreading for Sqlite, plus expression composition', extras_require={"tests":["mo-testing>=7.523.24033"]}, include_package_data=True, - install_requires=["jx-python==4.556.24070","mo-dots==9.549.24062","mo-files==6.556.24070","mo-future==7.546.24057","mo-imports==7.546.24057","mo-json==6.556.24070","mo-kwargs==7.551.24062","mo-logs==8.556.24070","mo-math==7.552.24062","mo-sql==4.556.24070","mo-sql==4.556.24070","mo-threads==6.556.24070","mo-times==5.556.24070"], + install_requires=["jx-python==4.568.24076","mo-dots==9.565.24076","mo-files==6.566.24076","mo-future==7.546.24057","mo-imports==7.546.24057","mo-json==6.566.24076","mo-kwargs==7.565.24076","mo-logs==8.566.24076","mo-math==7.565.24076","mo-sql==4.569.24076","mo-sql==4.569.24076","mo-threads==6.566.24076","mo-times==5.566.24076"], license='MPL 2.0', long_description='# More SQLite!\n\nMultithreading for Sqlite, plus expression composition\n\n\n[![PyPI Latest Release](https://img.shields.io/pypi/v/mo-sqlite.svg)](https://pypi.org/project/mo-sqlite/)\n[![Build Status](https://github.com/klahnakoski/mo-sqlite/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/klahnakoski/mo-sqlite/actions/workflows/build.yml)\n[![Coverage Status](https://coveralls.io/repos/github/klahnakoski/mo-sqlite/badge.svg?branch=dev)](https://coveralls.io/github/klahnakoski/mo-sqlite?branch=dev)\n[![Downloads](https://pepy.tech/badge/mo-sqlite/month)](https://pepy.tech/project/mo-sqlite)\n\n\n## Multi-threaded Sqlite\n\nThis module wraps the `sqlite3.connection` with thread-safe traffic manager. Here is typical usage: \n\n from mo_sqlite import Sqlite\n db = Sqlite("mydb.sqlite")\n with db.transaction() as t:\n t.command("insert into mytable values (1, 2, 3)")\n\nWhile you may have each thread own a `sqlite3.connection` to the same file, you will still get exceptions when another thread has the file locked.\n\n## Pull JSON out of database\n\nThis module includes a minimum experimental structure that can describe pulling deeply nested JSON documents out of a normalized database. The tactic is to shape a single query who\'s resultset can be easily converted to the desired JSON by Python. Read more on [pulling json from a database](docs/JSON%20in%20Database.md)\n\nThere are multiple normal forms, including domain key normal form, and columnar form; these have a multitude one-to-one relations, all represent the same logical schema, but differ in their access patterns to optimize for particular use cases. This module intends to hide the particular database schema from the caller; exposing just the logical schema. \n\n\n\nThis experiment compliments the [mo-columns](https://github.com/klahnakoski/mo-columns) experiment, which is about pushing JSON into a database. \n ', long_description_content_type='text/markdown', name='mo-sqlite', packages=["mo_sqlite","mo_sqlite.expressions"], url='https://github.com/klahnakoski/mo-sqlite', - version='2.558.24071' + version='2.569.24076' ) \ No newline at end of file diff --git a/packaging/setuptools.json b/packaging/setuptools.json index 3b08bf0..dc3210f 100644 --- a/packaging/setuptools.json +++ b/packaging/setuptools.json @@ -18,11 +18,11 @@ "extras_require": {"tests": ["mo-testing>=7.523.24033"]}, "include_package_data": true, "install_requires": [ - "jx-python==4.556.24070", "mo-dots==9.549.24062", "mo-files==6.556.24070", - "mo-future==7.546.24057", "mo-imports==7.546.24057", "mo-json==6.556.24070", - "mo-kwargs==7.551.24062", "mo-logs==8.556.24070", "mo-math==7.552.24062", - "mo-sql==4.556.24070", "mo-sql==4.556.24070", "mo-threads==6.556.24070", - "mo-times==5.556.24070" + "jx-python==4.568.24076", "mo-dots==9.565.24076", "mo-files==6.566.24076", + "mo-future==7.546.24057", "mo-imports==7.546.24057", "mo-json==6.566.24076", + "mo-kwargs==7.565.24076", "mo-logs==8.566.24076", "mo-math==7.565.24076", + "mo-sql==4.569.24076", "mo-sql==4.569.24076", "mo-threads==6.566.24076", + "mo-times==5.566.24076" ], "license": "MPL 2.0", "long_description": { @@ -66,5 +66,5 @@ "name": "mo-sqlite", "packages": ["mo_sqlite", "mo_sqlite.expressions"], "url": "https://github.com/klahnakoski/mo-sqlite", - "version": "2.558.24071" + "version": "2.569.24076" } \ No newline at end of file diff --git a/tests/requirements.lock b/tests/requirements.lock index b1d7682..4ed9a85 100644 --- a/tests/requirements.lock +++ b/tests/requirements.lock @@ -1,23 +1,23 @@ -# Tests pass with these versions 2024-03-11 +# Tests pass with these versions 2024-03-16 # pip install --no-deps -r tests/requirements.lock certifi==2024.2.2 charset-normalizer==3.3.2 hjson==3.1.0 idna==3.6 -jx-python==4.556.24070 -mo-collections==5.556.24070 -mo-dots==9.549.24062 -mo-files==6.556.24070 +jx-python==4.568.24076 +mo-collections==5.566.24076 +mo-dots==9.565.24076 +mo-files==6.566.24076 mo-future==7.546.24057 mo-imports==7.546.24057 -mo-json==6.556.24070 -mo-json-config==4.556.24070 -mo-kwargs==7.551.24062 -mo-logs==8.556.24070 -mo-math==7.552.24062 -mo-sql==4.556.24070 -mo-testing==7.523.24033 -mo-threads==6.556.24070 -mo-times==5.556.24070 +mo-json==6.566.24076 +mo-json-config==4.566.24076 +mo-kwargs==7.565.24076 +mo-logs==8.566.24076 +mo-math==7.565.24076 +mo-sql==4.569.24076 +mo-testing==7.562.24075 +mo-threads==6.566.24076 +mo-times==5.566.24076 requests==2.31.0 urllib3==2.2.0 \ No newline at end of file diff --git a/tests/requirements.txt b/tests/requirements.txt index 7ebe3e8..3d2896d 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1 +1 @@ -mo-testing>=7.523.24033 \ No newline at end of file +mo-testing>=7.562.24075 \ No newline at end of file