Skip to content

Commit 1ec428b

Browse files
committed
Polish sqlalchemy code and docs.
1 parent 82441cc commit 1ec428b

4 files changed

Lines changed: 15 additions & 8 deletions

File tree

docs/source/reference_guides/configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ are welcome to also support macOS.
4545
````{confval} database_url
4646
4747
pytask uses a database to keep track of tasks, products, and dependencies over runs. By
48-
default, it will create an SQLITE database in the project's root directory called
48+
default, it will create an SQLite database in the project's root directory called
4949
`.pytask.sqlite3`. If you want to use a different name or a different dialect
5050
[supported by sqlalchemy](https://docs.sqlalchemy.org/en/latest/core/engines.html#backend-specific-urls),
5151
use either {option}`pytask build --database-url` or `database_url` in the config.
@@ -54,7 +54,7 @@ use either {option}`pytask build --database-url` or `database_url` in the config
5454
database_url = "sqlite:///.pytask.sqlite3"
5555
```
5656
57-
Relative paths for SQLITE databases are interpreted as either relative to the
57+
Relative paths for SQLite databases are interpreted as either relative to the
5858
configuration file or the root directory.
5959
6060
````

src/_pytask/database_utils.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,21 @@
1313
from sqlalchemy.orm import sessionmaker
1414

1515

16-
__all__ = ["create_database", "update_states_in_database", "DatabaseSession"]
16+
__all__ = [
17+
"create_database",
18+
"update_states_in_database",
19+
"BaseTable",
20+
"DatabaseSession",
21+
]
1722

1823

1924
DatabaseSession = sessionmaker()
2025

2126

22-
Base = declarative_base()
27+
BaseTable = declarative_base()
2328

2429

25-
class State(Base): # type: ignore[valid-type, misc]
30+
class State(BaseTable): # type: ignore[valid-type, misc]
2631
"""Represent the state of a node in relation to a task."""
2732

2833
__tablename__ = "state"
@@ -37,7 +42,7 @@ def create_database(url: str) -> None:
3742
"""Create the database."""
3843
try:
3944
engine = create_engine(url)
40-
Base.metadata.create_all(bind=engine)
45+
BaseTable.metadata.create_all(bind=engine)
4146
DatabaseSession.configure(bind=engine)
4247
except Exception:
4348
raise

src/_pytask/profile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from _pytask.config import hookimpl
2020
from _pytask.console import console
2121
from _pytask.console import format_task_id
22-
from _pytask.database_utils import Base
22+
from _pytask.database_utils import BaseTable
2323
from _pytask.database_utils import DatabaseSession
2424
from _pytask.exceptions import CollectionError
2525
from _pytask.exceptions import ConfigurationError
@@ -47,7 +47,7 @@ class _ExportFormats(enum.Enum):
4747
CSV = "csv"
4848

4949

50-
class Runtime(Base): # type: ignore[valid-type, misc]
50+
class Runtime(BaseTable): # type: ignore[valid-type, misc]
5151
"""Record of runtimes of tasks."""
5252

5353
__tablename__ = "runtime"

src/pytask/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from _pytask.compat import import_optional_dependency
1414
from _pytask.config import hookimpl
1515
from _pytask.console import console
16+
from _pytask.database_utils import BaseTable
1617
from _pytask.database_utils import create_database
1718
from _pytask.database_utils import DatabaseSession
1819
from _pytask.database_utils import State
@@ -65,6 +66,7 @@
6566

6667

6768
__all__ = [
69+
"BaseTable",
6870
"CollectionError",
6971
"CollectionMetadata",
7072
"CollectionOutcome",

0 commit comments

Comments
 (0)