[WIP] Added support for asyncpg as an optional engine#125
Open
hzlmn wants to merge 3 commits intoaio-libs:masterfrom
Open
[WIP] Added support for asyncpg as an optional engine#125hzlmn wants to merge 3 commits intoaio-libs:masterfrom
hzlmn wants to merge 3 commits intoaio-libs:masterfrom
Conversation
Arfey
requested changes
Apr 28, 2019
| {%- if cookiecutter.use_postgres == 'y' %} | ||
| from {{ cookiecutter.project_name }}.migrations import metadata | ||
| from {{ cookiecutter.project_name }}.users.tables import users | ||
| from {{cookiecutter.project_name}}.utils.common import PATH, get_config |
Member
There was a problem hiding this comment.
In the whole project uses {{ cookiecutter.project_name }} with indent, so don't change that, please.
In jinja2 documentation also use indents
{% for user in users %}
<li><a href="{{ user.url }}">{{ user.username }}</a></li>
{% endfor %}
Contributor
Author
There was a problem hiding this comment.
sorry autoformatting, my bad.
| import asyncpg | ||
| return await asyncpg.connect(**test_config['postgres']) | ||
| {%- endif %} | ||
|
|
Member
There was a problem hiding this comment.
I think that for compatibiliti with tests u should use asyncpgsa and just rewrite sa_engine some like that:
from sqlalchemy import create_engine
...
return await create_engine(dsn, echo=True, module=asyncpgsa)what do u think?
| @@ -1,8 +1,8 @@ | |||
| {%- if cookiecutter.use_postgres == 'y' %} | |||
| {%- if cookiecutter.use_postgres == 'aiopg' %} | |||
Member
There was a problem hiding this comment.
Types are important, so u need create types for asyncpg
| from {{cookiecutter.project_name}}.users.tables import users{%- if cookiecutter.use_postgres == 'asyncpg' %}, dialect {%- endif %} | ||
|
|
||
| from {{ cookiecutter.project_name }}.users.tables import users | ||
| __all__ = ['select_user_by_id', 'select_user_by_id_query'] |
|
|
||
| from {{ cookiecutter.project_name }}.migrations import metadata | ||
| from {{ cookiecutter.project_name }}.users.enums import UserGender | ||
| from {{cookiecutter.project_name}}.migrations import metadata |
|
|
||
| gender_enum = postgresql.ENUM(UserGender) | ||
|
|
||
| dialect = postgresql.dialect() |
Member
There was a problem hiding this comment.
this part need only for asyncpg, so use if statement
|
|
||
| @pytest.fixture | ||
| async def client(aiohttp_client{% if cookiecutter.use_postgres == 'y' %}, tables{% endif %}): | ||
| async def client(aiohttp_client {% if cookiecutter.use_postgres != 'n' %} , tables{% endif %}): |
Member
There was a problem hiding this comment.
why did u add indent here? this code generate
async def client(aiohttp_client , tables):
...right?
This comment has been minimized.
This comment has been minimized.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What do these changes do?
Closes #27
Are there changes in behavior for the user?
Related issue number
Checklist
CONTRIBUTORS.txt<Name> <Surname>.CHANGESfolder<issue_id>.<type>(e.g.588.bugfix)issue_idchange it to the pr id after creating the PR.feature: Signifying a new feature..bugfix: Signifying a bug fix..doc: Signifying a documentation improvement..removal: Signifying a deprecation or removal of public API..misc: A ticket has been closed, but it is not of interest to users.Fix issue with non-ascii contents in doctest text files.