-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Added support for asyncpg as an optional engine #125
base: master
Are you sure you want to change the base?
Conversation
{%- 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 %}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry autoformatting, my bad.
import asyncpg | ||
return await asyncpg.connect(**test_config['postgres']) | ||
{%- endif %} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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' %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Types are important, so u need create types for asyncpg
|
||
from {{ cookiecutter.project_name }}.users.tables import users | ||
__all__ = ['select_user_by_id', 'select_user_by_id_query'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -1,15 +1,16 @@ | |||
import sqlalchemy as sa | |||
from sqlalchemy.dialects import postgresql | |||
|
|||
from {{ cookiecutter.project_name }}.migrations import metadata | |||
from {{ cookiecutter.project_name }}.users.enums import UserGender | |||
from {{cookiecutter.project_name}}.migrations import metadata |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indents
|
||
|
||
gender_enum = postgresql.ENUM(UserGender) | ||
|
||
dialect = postgresql.dialect() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this part need only for asyncpg, so use if statement
{%- endif %} | ||
|
||
|
||
@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 %}): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did u add indent here? this code generate
async def client(aiohttp_client , tables):
...
right?
What do these changes do?
Closes #27
Are there changes in behavior for the user?
Related issue number
Checklist
CONTRIBUTORS.txt
<Name> <Surname>
.CHANGES
folder<issue_id>.<type>
(e.g.588.bugfix
)issue_id
change 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.