-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated configs, docs and some code for Asphalt 5
- Loading branch information
Showing
6 changed files
with
43 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,9 +24,7 @@ jobs: | |
- name: Start external services | ||
run: docker compose up -d | ||
- name: Install dependencies | ||
run: | | ||
pip install git+https://github.com/asphalt-framework/[email protected] | ||
pip install -e .[test] coverage | ||
run: pip install -e .[test] | ||
- name: Test with pytest | ||
run: coverage run -m pytest -v | ||
- name: Generate coverage report | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,16 +5,16 @@ Configuration | |
|
||
A typical SQLAlchemy configuration consists of a single database. | ||
At minimum, you only need a connection URL (see the | ||
`SQLAlchemy documentation`_ for how to construct one). Such a configuration would look | ||
something like this:: | ||
:doc:`SQLAlchemy documentation <sqlalchemy:tutorial/engine>` on how to construct one). | ||
Such a configuration would look something like this:: | ||
|
||
components: | ||
sqlalchemy: | ||
url: postgresql+asyncpg://user:[email protected]/mydatabase | ||
url: postgresql+psycopg://user:[email protected]/mydatabase | ||
|
||
This will add two static resources and one resource factory, as follows: | ||
|
||
* engine (type: :class:`sqlalchemy.future.engine.Engine` or | ||
* engine (type: :class:`sqlalchemy.engine.Engine` or | ||
:class:`sqlalchemy.ext.asyncio.AsyncEngine`) | ||
* sessionmaker (type: :class:`sqlalchemy.orm.sessionmaker`) | ||
* session factory (generates :class:`~sqlalchemy.orm.Session` or | ||
|
@@ -26,23 +26,22 @@ sharing features):: | |
components: | ||
sqlalchemy: | ||
url: | ||
drivername: postgresql+asyncpg | ||
drivername: postgresql+psycopg | ||
username: user | ||
password: password | ||
host: 10.0.0.8 | ||
database: mydatabase | ||
|
||
.. seealso:: | ||
* :class:`sqlalchemy.engine.URL` | ||
* :class:`asphalt.sqlalchemy.component.SQLAlchemyComponent` | ||
|
||
.. _SQLAlchemy documentation: https://docs.sqlalchemy.org/en/14/core/engines.html | ||
* :class:`asphalt.sqlalchemy.SQLAlchemyComponent` | ||
|
||
Setting engine or session options | ||
--------------------------------- | ||
|
||
If you need to adjust the options used for creating new sessions, or pass extra | ||
arguments to the engine, you can do so by specifying them in the ``session`` option:: | ||
arguments to the engine, you can do so by specifying them in the ``session_args`` and | ||
``engine_args``, respectively:: | ||
|
||
components: | ||
sqlalchemy: | ||
|
@@ -52,20 +51,3 @@ arguments to the engine, you can do so by specifying them in the ``session`` opt | |
session_args: | ||
info: | ||
hello: world | ||
|
||
Multiple databases | ||
------------------ | ||
|
||
If you need to work with multiple databases, you will need to use multiple instances | ||
of the ``sqlalchemy`` component:: | ||
|
||
components: | ||
sqlalchemy: | ||
resource_name: db1 | ||
url: postgresql+asyncpg:///mydatabase | ||
sqlalchemy/db2: | ||
resource_name: db2 | ||
url: sqlite+aiosqlite:///mydb.sqlite | ||
|
||
This will make the appropriate resources available using their respective namespaces | ||
(``db1`` or ``db2`` instead of ``default``). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters