Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-databases for
openSUSE:Factory checked in at 2023-06-06 19:56:09
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-databases (Old)
and /work/SRC/openSUSE:Factory/.python-databases.new.15902 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-databases"
Tue Jun 6 19:56:09 2023 rev:7 rq:1091001 version:0.7.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-databases/python-databases.changes
2022-11-25 13:22:15.111387417 +0100
+++
/work/SRC/openSUSE:Factory/.python-databases.new.15902/python-databases.changes
2023-06-06 19:56:54.202702389 +0200
@@ -1,0 +2,9 @@
+Tue Jun 6 01:56:24 UTC 2023 - Steve Kowalik <[email protected]>
+
+- Update to 0.7.0:
+ * Fixed breaking changes in SQLAlchemy cursor; supports >=1.4.42,<1.5
+ * Wrapped types in typing.Optional where applicable
+- Change {Build,}Requires for SQLAlchemy so we don't install >= 2.
+- Drop patch sqlalchemy1442.patch, included upstream.
+
+-------------------------------------------------------------------
Old:
----
databases-0.6.2.tar.gz
sqlalchemy1442.patch
New:
----
databases-0.7.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-databases.spec ++++++
--- /var/tmp/diff_new_pack.U93FRJ/_old 2023-06-06 19:56:54.806705969 +0200
+++ /var/tmp/diff_new_pack.U93FRJ/_new 2023-06-06 19:56:54.814706017 +0200
@@ -1,7 +1,7 @@
#
# spec file for package python-databases
#
-# Copyright (c) 2022 SUSE LLC
+# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -18,21 +18,16 @@
%define skip_python2 1
Name: python-databases
-Version: 0.6.2
+Version: 0.7.0
Release: 0
Summary: Async database support for Python
License: BSD-3-Clause
URL: https://github.com/encode/databases
Source:
https://github.com/encode/databases/archive/%{version}.tar.gz#/databases-%{version}.tar.gz
-# PATCH-FIX-UPSTREAM sqlalchemy1442.patch gh#encode/databases#513
-Patch: sqlalchemy1442.patch
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
-Requires: python-sqlalchemy >= 1.4
-%if 0%{?python_version_nodots} < 37
-Requires: python-aiocontextvars
-%endif
+Requires: (python-sqlalchemy >= 1.4 with python-sqlalchemy < 2)
Suggests: python-aiomysql
Suggests: python-aiopg
Suggests: python-aiosqlite
@@ -40,11 +35,10 @@
BuildArch: noarch
# SECTION test requirements
BuildRequires: %{python_module aiosqlite}
-BuildRequires: %{python_module aiocontextvars if %python-base < 3.7}
BuildRequires: %{python_module asyncpg}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module requests}
-BuildRequires: %{python_module sqlalchemy >= 1.4}
+BuildRequires: %{python_module sqlalchemy >= 1.4 with %python-sqlalchemy < 2}
# /SECTION
%python_subpackages
++++++ databases-0.6.2.tar.gz -> databases-0.7.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/databases-0.6.2/CHANGELOG.md
new/databases-0.7.0/CHANGELOG.md
--- old/databases-0.6.2/CHANGELOG.md 2022-11-07 12:15:27.000000000 +0100
+++ new/databases-0.7.0/CHANGELOG.md 2022-12-18 10:14:45.000000000 +0100
@@ -4,9 +4,16 @@
The format is based on [Keep a
Changelog](https://keepachangelog.com/en/1.0.0/).
+## 0.7.0 (Dec 18th, 2022)
+
+### Fixed
+
+* Fixed breaking changes in SQLAlchemy cursor; supports `>=1.4.42,<1.5` (#513).
+* Wrapped types in `typing.Optional` where applicable (#510).
+
## 0.6.2 (Nov 7th, 2022)
-### Changes
+### Changed
* Pinned SQLAlchemy `<=1.4.41` to avoid breaking changes (#520).
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/databases-0.6.2/databases/__init__.py
new/databases-0.7.0/databases/__init__.py
--- old/databases-0.6.2/databases/__init__.py 2022-11-07 12:15:27.000000000
+0100
+++ new/databases-0.7.0/databases/__init__.py 2022-12-18 10:14:45.000000000
+0100
@@ -1,4 +1,4 @@
from databases.core import Database, DatabaseURL
-__version__ = "0.6.2"
+__version__ = "0.7.0"
__all__ = ["Database", "DatabaseURL"]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/databases-0.6.2/databases/backends/aiopg.py
new/databases-0.7.0/databases/backends/aiopg.py
--- old/databases-0.6.2/databases/backends/aiopg.py 2022-11-07
12:15:27.000000000 +0100
+++ new/databases-0.7.0/databases/backends/aiopg.py 2022-12-18
10:14:45.000000000 +0100
@@ -221,6 +221,7 @@
compiled._result_columns,
compiled._ordered_columns,
compiled._textual_ordered_columns,
+ compiled._ad_hoc_textual,
compiled._loose_column_name_matching,
)
else:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/databases-0.6.2/databases/backends/asyncmy.py
new/databases-0.7.0/databases/backends/asyncmy.py
--- old/databases-0.6.2/databases/backends/asyncmy.py 2022-11-07
12:15:27.000000000 +0100
+++ new/databases-0.7.0/databases/backends/asyncmy.py 2022-12-18
10:14:45.000000000 +0100
@@ -211,6 +211,7 @@
compiled._result_columns,
compiled._ordered_columns,
compiled._textual_ordered_columns,
+ compiled._ad_hoc_textual,
compiled._loose_column_name_matching,
)
else:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/databases-0.6.2/databases/backends/mysql.py
new/databases-0.7.0/databases/backends/mysql.py
--- old/databases-0.6.2/databases/backends/mysql.py 2022-11-07
12:15:27.000000000 +0100
+++ new/databases-0.7.0/databases/backends/mysql.py 2022-12-18
10:14:45.000000000 +0100
@@ -211,6 +211,7 @@
compiled._result_columns,
compiled._ordered_columns,
compiled._textual_ordered_columns,
+ compiled._ad_hoc_textual,
compiled._loose_column_name_matching,
)
else:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/databases-0.6.2/databases/backends/sqlite.py
new/databases-0.7.0/databases/backends/sqlite.py
--- old/databases-0.6.2/databases/backends/sqlite.py 2022-11-07
12:15:27.000000000 +0100
+++ new/databases-0.7.0/databases/backends/sqlite.py 2022-12-18
10:14:45.000000000 +0100
@@ -185,6 +185,7 @@
compiled._result_columns,
compiled._ordered_columns,
compiled._textual_ordered_columns,
+ compiled._ad_hoc_textual,
compiled._loose_column_name_matching,
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/databases-0.6.2/databases/core.py
new/databases-0.7.0/databases/core.py
--- old/databases-0.6.2/databases/core.py 2022-11-07 12:15:27.000000000
+0100
+++ new/databases-0.7.0/databases/core.py 2022-12-18 10:14:45.000000000
+0100
@@ -129,20 +129,24 @@
async def __aexit__(
self,
- exc_type: typing.Type[BaseException] = None,
- exc_value: BaseException = None,
- traceback: TracebackType = None,
+ exc_type: typing.Optional[typing.Type[BaseException]] = None,
+ exc_value: typing.Optional[BaseException] = None,
+ traceback: typing.Optional[TracebackType] = None,
) -> None:
await self.disconnect()
async def fetch_all(
- self, query: typing.Union[ClauseElement, str], values: dict = None
+ self,
+ query: typing.Union[ClauseElement, str],
+ values: typing.Optional[dict] = None,
) -> typing.List[Record]:
async with self.connection() as connection:
return await connection.fetch_all(query, values)
async def fetch_one(
- self, query: typing.Union[ClauseElement, str], values: dict = None
+ self,
+ query: typing.Union[ClauseElement, str],
+ values: typing.Optional[dict] = None,
) -> typing.Optional[Record]:
async with self.connection() as connection:
return await connection.fetch_one(query, values)
@@ -150,14 +154,16 @@
async def fetch_val(
self,
query: typing.Union[ClauseElement, str],
- values: dict = None,
+ values: typing.Optional[dict] = None,
column: typing.Any = 0,
) -> typing.Any:
async with self.connection() as connection:
return await connection.fetch_val(query, values, column=column)
async def execute(
- self, query: typing.Union[ClauseElement, str], values: dict = None
+ self,
+ query: typing.Union[ClauseElement, str],
+ values: typing.Optional[dict] = None,
) -> typing.Any:
async with self.connection() as connection:
return await connection.execute(query, values)
@@ -169,7 +175,9 @@
return await connection.execute_many(query, values)
async def iterate(
- self, query: typing.Union[ClauseElement, str], values: dict = None
+ self,
+ query: typing.Union[ClauseElement, str],
+ values: typing.Optional[dict] = None,
) -> typing.AsyncGenerator[typing.Mapping, None]:
async with self.connection() as connection:
async for record in connection.iterate(query, values):
@@ -232,9 +240,9 @@
async def __aexit__(
self,
- exc_type: typing.Type[BaseException] = None,
- exc_value: BaseException = None,
- traceback: TracebackType = None,
+ exc_type: typing.Optional[typing.Type[BaseException]] = None,
+ exc_value: typing.Optional[BaseException] = None,
+ traceback: typing.Optional[TracebackType] = None,
) -> None:
async with self._connection_lock:
assert self._connection is not None
@@ -243,14 +251,18 @@
await self._connection.release()
async def fetch_all(
- self, query: typing.Union[ClauseElement, str], values: dict = None
+ self,
+ query: typing.Union[ClauseElement, str],
+ values: typing.Optional[dict] = None,
) -> typing.List[Record]:
built_query = self._build_query(query, values)
async with self._query_lock:
return await self._connection.fetch_all(built_query)
async def fetch_one(
- self, query: typing.Union[ClauseElement, str], values: dict = None
+ self,
+ query: typing.Union[ClauseElement, str],
+ values: typing.Optional[dict] = None,
) -> typing.Optional[Record]:
built_query = self._build_query(query, values)
async with self._query_lock:
@@ -259,7 +271,7 @@
async def fetch_val(
self,
query: typing.Union[ClauseElement, str],
- values: dict = None,
+ values: typing.Optional[dict] = None,
column: typing.Any = 0,
) -> typing.Any:
built_query = self._build_query(query, values)
@@ -267,7 +279,9 @@
return await self._connection.fetch_val(built_query, column)
async def execute(
- self, query: typing.Union[ClauseElement, str], values: dict = None
+ self,
+ query: typing.Union[ClauseElement, str],
+ values: typing.Optional[dict] = None,
) -> typing.Any:
built_query = self._build_query(query, values)
async with self._query_lock:
@@ -281,7 +295,9 @@
await self._connection.execute_many(queries)
async def iterate(
- self, query: typing.Union[ClauseElement, str], values: dict = None
+ self,
+ query: typing.Union[ClauseElement, str],
+ values: typing.Optional[dict] = None,
) -> typing.AsyncGenerator[typing.Any, None]:
built_query = self._build_query(query, values)
async with self.transaction():
@@ -303,7 +319,7 @@
@staticmethod
def _build_query(
- query: typing.Union[ClauseElement, str], values: dict = None
+ query: typing.Union[ClauseElement, str], values: typing.Optional[dict]
= None
) -> ClauseElement:
if isinstance(query, str):
query = text(query)
@@ -338,9 +354,9 @@
async def __aexit__(
self,
- exc_type: typing.Type[BaseException] = None,
- exc_value: BaseException = None,
- traceback: TracebackType = None,
+ exc_type: typing.Optional[typing.Type[BaseException]] = None,
+ exc_value: typing.Optional[BaseException] = None,
+ traceback: typing.Optional[TracebackType] = None,
) -> None:
"""
Called when exiting `async with database.transaction()`
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/databases-0.6.2/docs/database_queries.md
new/databases-0.7.0/docs/database_queries.md
--- old/databases-0.6.2/docs/database_queries.md 2022-11-07
12:15:27.000000000 +0100
+++ new/databases-0.7.0/docs/database_queries.md 2022-12-18
10:14:45.000000000 +0100
@@ -24,9 +24,48 @@
)
```
-You can use any of the sqlalchemy column types such as `sqlalchemy.JSON`, or
+You can use any of the SQLAlchemy column types such as `sqlalchemy.JSON`, or
custom column types.
+## Creating tables
+
+Databases doesn't use SQLAlchemy's engine for database access internally. [The
usual SQLAlchemy core way to create tables with
`create_all`](https://docs.sqlalchemy.org/en/20/core/metadata.html#sqlalchemy.schema.MetaData.create_all)
is therefore not available. To work around this you can use SQLAlchemy to
[compile the query to
SQL](https://docs.sqlalchemy.org/en/20/faq/sqlexpressions.html#how-do-i-render-sql-expressions-as-strings-possibly-with-bound-parameters-inlined)
and then execute it with databases:
+
+```python
+from databases import Database
+import sqlalchemy
+
+database = Database("postgresql+asyncpg://localhost/example")
+
+# Establish the connection pool
+await database.connect()
+
+metadata = sqlalchemy.MetaData()
+dialect = sqlalchemy.dialects.postgresql.dialect()
+
+# Define your table(s)
+notes = sqlalchemy.Table(
+ "notes",
+ metadata,
+ sqlalchemy.Column("id", sqlalchemy.Integer, primary_key=True),
+ sqlalchemy.Column("text", sqlalchemy.String(length=100)),
+ sqlalchemy.Column("completed", sqlalchemy.Boolean),
+)
+
+# Create tables
+for table in metadata.tables.values():
+ # Set `if_not_exists=False` if you want the query to throw an
+ # exception when the table already exists
+ schema = sqlalchemy.schema.CreateTable(table, if_not_exists=True)
+ query = str(schema.compile(dialect=dialect))
+ await database.execute(query=query)
+
+# Close all connections in the connection pool
+await database.disconnect()
+```
+
+Note that this way of creating tables is only useful for local
experimentation. For serious projects, we recommend using a proper database
schema migrations solution like
[Alembic](https://alembic.sqlalchemy.org/en/latest/).
+
## Queries
You can now use any [SQLAlchemy core][sqlalchemy-core] queries ([official
tutorial][sqlalchemy-core-tutorial]).
@@ -70,11 +109,11 @@
async for row in database.iterate(query=query):
...
-# Close all connection in the connection pool
+# Close all connections in the connection pool
await database.disconnect()
```
-Connections are managed as task-local state, with driver implementations
+Connections are managed as a task-local state, with driver implementations
transparently using connection pooling behind the scenes.
## Raw queries
@@ -107,21 +146,21 @@
Note that query arguments should follow the `:query_arg` style.
[sqlalchemy-core]: https://docs.sqlalchemy.org/en/latest/core/
-[sqlalchemy-core-tutorial]:
https://docs.sqlalchemy.org/en/latest/core/tutorial.html
+[sqlalchemy-core-tutorial]:
https://docs.sqlalchemy.org/en/14/core/tutorial.html
## Query result
-To keep in line with [SQLAlchemy 1.4 changes][sqlalchemy-mapping-changes]
-query result object no longer implements a mapping interface.
-To access query result as a mapping you should use the `_mapping` property.
-That way you can process both SQLAlchemy Rows and databases Records from raw
queries
+To keep in line with [SQLAlchemy 1.4 changes][sqlalchemy-mapping-changes]
+query result object no longer implements a mapping interface.
+To access query result as a mapping you should use the `_mapping` property.
+That way you can process both SQLAlchemy Rows and databases Records from raw
queries
with the same function without any instance checks.
```python
query = "SELECT * FROM notes WHERE id = :id"
result = await database.fetch_one(query=query, values={"id": 1})
-result.id # access field via attribute
-result._mapping['id'] # access field via mapping
+result.id # Access field via attribute
+result._mapping['id'] # Access field via mapping
```
[sqlalchemy-mapping-changes]:
https://docs.sqlalchemy.org/en/14/changelog/migration_14.html#rowproxy-is-no-longer-a-proxy-is-now-called-row-and-behaves-like-an-enhanced-named-tuple
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/databases-0.6.2/setup.cfg
new/databases-0.7.0/setup.cfg
--- old/databases-0.6.2/setup.cfg 2022-11-07 12:15:27.000000000 +0100
+++ new/databases-0.7.0/setup.cfg 2022-12-18 10:14:45.000000000 +0100
@@ -1,6 +1,7 @@
[mypy]
disallow_untyped_defs = True
ignore_missing_imports = True
+no_implicit_optional = True
[tool:isort]
profile = black
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/databases-0.6.2/setup.py new/databases-0.7.0/setup.py
--- old/databases-0.6.2/setup.py 2022-11-07 12:15:27.000000000 +0100
+++ new/databases-0.7.0/setup.py 2022-12-18 10:14:45.000000000 +0100
@@ -47,7 +47,7 @@
author_email="[email protected]",
packages=get_packages("databases"),
package_data={"databases": ["py.typed"]},
- install_requires=["sqlalchemy>=1.4,<=1.4.41"],
+ install_requires=["sqlalchemy>=1.4.42,<1.5"],
extras_require={
"postgresql": ["asyncpg"],
"asyncpg": ["asyncpg"],