Skip to content
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

Why require psycopg for databases[postgresql]? #198

Closed
retnikt opened this issue Apr 27, 2020 · 3 comments
Closed

Why require psycopg for databases[postgresql]? #198

retnikt opened this issue Apr 27, 2020 · 3 comments

Comments

@retnikt
Copy link
Contributor

retnikt commented Apr 27, 2020

When installing databases with asyncpg PostgreSQL support using pip install databases[postgresql], psycopg2-binary is installed as well. This is not recommended, and seems also unnecessary given that there are no references to it in the code, and asyncpg does not require it. Is there any reason for including it as a dependency or is it just a relic of an older version?

@fullonic
Copy link

The need of psycopg2 is related with sqlalchemy, which databases depends on. But you are right, it shouldn't be the binary version.

@tomchristie
Copy link
Member

We could consider removing it entirely. (And the corresponding mysql sync driver too.)

databases itself doesn't require them, but you do need them if you want to do engine.create_all, or if you want to use alembic for database migrations. (In practice you're almost certainly going to want to do one of those.)

I guess a first step here might be - we'll accept a pull request switching it to the non-binary version, and we can follow up if there's any problems with that.

retnikt added a commit to retnikt/databases that referenced this issue May 1, 2020
retnikt added a commit to retnikt/databases that referenced this issue May 1, 2020
vmarkovtsev added a commit to vmarkovtsev/databases that referenced this issue Oct 19, 2020
Changelog:

- Use backend native fetch_val() implementation when available (encode#132)
- Replace psycopg2-binary with psycopg2 (encode#198) (encode#204)
- Speed up PostgresConnection fetch() and iterate() (encode#193)
- Access asyncpg Record field by key on raw query (encode#207)
- Fix type hinting for sqlite backend (encode#227)
- Allow setting min_size and max_size in postgres DSN (encode#210)
- Add option pool_recycle in postgres DSN (encode#233)
- Fix SQLAlchemy DDL statements (encode#226)
- Make fetch_val call fetch_one for type conversion (encode#246)
- Allow extra transaction options (encode#242)
- Unquote username and password in DatabaseURL (encode#248)
vmarkovtsev added a commit to vmarkovtsev/databases that referenced this issue Oct 19, 2020
Changelog:

- Use backend native fetch_val() implementation when available (encode#132)
- Replace psycopg2-binary with psycopg2 (encode#198) (encode#204)
- Speed up PostgresConnection fetch() and iterate() (encode#193)
- Access asyncpg Record field by key on raw query (encode#207)
- Fix type hinting for sqlite backend (encode#227)
- Allow setting min_size and max_size in postgres DSN (encode#210)
- Add option pool_recycle in postgres DSN (encode#233)
- Fix SQLAlchemy DDL statements (encode#226)
- Make fetch_val call fetch_one for type conversion (encode#246)
- Allow extra transaction options (encode#242)
- Unquote username and password in DatabaseURL (encode#248)
vmarkovtsev added a commit to vmarkovtsev/databases that referenced this issue Oct 20, 2020
Changelog:

- Use backend native fetch_val() implementation when available (encode#132)
- Replace psycopg2-binary with psycopg2 (encode#198) (encode#204)
- Speed up PostgresConnection fetch() and iterate() (encode#193)
- Access asyncpg Record field by key on raw query (encode#207)
- Fix type hinting for sqlite backend (encode#227)
- Allow setting min_size and max_size in postgres DSN (encode#210)
- Add option pool_recycle in postgres DSN (encode#233)
- Fix SQLAlchemy DDL statements (encode#226)
- Make fetch_val call fetch_one for type conversion (encode#246)
- Allow extra transaction options (encode#242)
- Unquote username and password in DatabaseURL (encode#248)
vmarkovtsev added a commit to vmarkovtsev/databases that referenced this issue Oct 20, 2020
Changelog:

- Use backend native fetch_val() implementation when available (encode#132)
- Replace psycopg2-binary with psycopg2 (encode#198) (encode#204)
- Speed up PostgresConnection fetch() and iterate() (encode#193)
- Access asyncpg Record field by key on raw query (encode#207)
- Fix type hinting for sqlite backend (encode#227)
- Allow setting min_size and max_size in postgres DSN (encode#210)
- Add option pool_recycle in postgres DSN (encode#233)
- Fix SQLAlchemy DDL statements (encode#226)
- Make fetch_val call fetch_one for type conversion (encode#246)
- Allow extra transaction options (encode#242)
- Unquote username and password in DatabaseURL (encode#248)
vmarkovtsev added a commit that referenced this issue Oct 20, 2020
Changelog:

- Use backend native fetch_val() implementation when available (#132)
- Replace psycopg2-binary with psycopg2 (#198) (#204)
- Speed up PostgresConnection fetch() and iterate() (#193)
- Access asyncpg Record field by key on raw query (#207)
- Fix type hinting for sqlite backend (#227)
- Allow setting min_size and max_size in postgres DSN (#210)
- Add option pool_recycle in postgres DSN (#233)
- Fix SQLAlchemy DDL statements (#226)
- Make fetch_val call fetch_one for type conversion (#246)
- Allow extra transaction options (#242)
- Unquote username and password in DatabaseURL (#248)
@jpic
Copy link

jpic commented Feb 6, 2021

Not sure if this helps, but async create_all is in SQLA 1.4b1:

with engine.begin() as conn:         
    await conn.run_sync(metadata.create_all)

Maybe that'll also be an option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants