# flake8-sqlalchemy
[![PyPI current version](https://img.shields.io/pypi/v/flake8-sqlalchemy.svg)](https://pypi.python.org/pypi/flake8-sqlalchemy)
[![Python Support](https://img.shields.io/pypi/pyversions/flake8-sqlalchemy.svg)](https://pypi.python.org/pypi/flake8-sqlalchemy)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/miketheman/flake8-sqlalchemy/main.svg)](https://results.pre-commit.ci/latest/github/miketheman/flake8-sqlalchemy/main)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
A flake8 plugin for SQLAlchemy code.
## Installation
```bash
pip install flake8-sqlalchemy
```
## Configuration
By default, all checks are enabled.
You can disable **all** checks by adding the following to your `setup.cfg`:
```ini
[flake8]
ignore = SQA
```
or ignore specific checks:
```ini
[flake8]
ignore = SQA100
```
### `SQA100` - `sqlalchemy` import alias
Checks that when `sqlalchemy` is imported with an alias,
the alias is either `sa` or `db`.
#### Bad
```python
import sqlalchemy as foo
```
#### Good
```python
import sqlalchemy as sa
# or
import sqlalchemy as db
```
### `SQA200` - `Column` keyword argument `comment` required
When writing a `Column` definition the `comment` keyword argument is required.
This provides inline documentation for the column,
as well as generating the SQL to add the comment to the database.
#### Bad
```python
class Users(Base):
__tablename__ = "users"
id = Column(Integer, primary_key=True)
name = Column(String)
```
#### Good
```python
class Users(Base):
__tablename__ = "users"
id = Column(Integer, primary_key=True, comment="User ID from Auth Service")
name = Column(String, comment="User name: first, middle, last")
```
Also applies to `mapped_column`:
```python
class Users(Base):
__tablename__ = "users"
id = Column(Integer, primary_key=True, comment="User ID from Auth Service")
name = mapped_column(String, comment="User name: first, middle, last")
```
## License
This project is licensed under the terms of the MIT license.
See the [LICENSE](LICENSE.md) file for the full license text.
## Author
- [Mike Fiedler](https://github.com/miketheman)
Raw data
{
"_id": null,
"home_page": "https://github.com/miketheman/flake8-sqlalchemy",
"name": "flake8-sqlalchemy",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8.1,<4.0.0",
"maintainer_email": "",
"keywords": "flake8,lint,sqlalchemy",
"author": "Mike Fiedler",
"author_email": "miketheman@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/d8/d6/fe5646eb1c8e5f0260642128859195e6cc2ff7542356edeccebe90f63ef6/flake8_sqlalchemy-0.2.0.tar.gz",
"platform": null,
"description": "# flake8-sqlalchemy\n\n[![PyPI current version](https://img.shields.io/pypi/v/flake8-sqlalchemy.svg)](https://pypi.python.org/pypi/flake8-sqlalchemy)\n[![Python Support](https://img.shields.io/pypi/pyversions/flake8-sqlalchemy.svg)](https://pypi.python.org/pypi/flake8-sqlalchemy)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/miketheman/flake8-sqlalchemy/main.svg)](https://results.pre-commit.ci/latest/github/miketheman/flake8-sqlalchemy/main)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\nA flake8 plugin for SQLAlchemy code.\n\n## Installation\n\n```bash\npip install flake8-sqlalchemy\n```\n\n## Configuration\n\nBy default, all checks are enabled.\nYou can disable **all** checks by adding the following to your `setup.cfg`:\n\n```ini\n[flake8]\nignore = SQA\n```\n\nor ignore specific checks:\n\n```ini\n[flake8]\nignore = SQA100\n```\n\n### `SQA100` - `sqlalchemy` import alias\n\nChecks that when `sqlalchemy` is imported with an alias,\nthe alias is either `sa` or `db`.\n\n#### Bad\n\n```python\nimport sqlalchemy as foo\n```\n\n#### Good\n\n```python\nimport sqlalchemy as sa\n# or\nimport sqlalchemy as db\n```\n\n### `SQA200` - `Column` keyword argument `comment` required\n\nWhen writing a `Column` definition the `comment` keyword argument is required.\nThis provides inline documentation for the column,\nas well as generating the SQL to add the comment to the database.\n\n#### Bad\n\n```python\nclass Users(Base):\n __tablename__ = \"users\"\n\n id = Column(Integer, primary_key=True)\n name = Column(String)\n```\n\n#### Good\n\n```python\nclass Users(Base):\n __tablename__ = \"users\"\n\n id = Column(Integer, primary_key=True, comment=\"User ID from Auth Service\")\n name = Column(String, comment=\"User name: first, middle, last\")\n```\n\nAlso applies to `mapped_column`:\n\n```python\nclass Users(Base):\n __tablename__ = \"users\"\n\n id = Column(Integer, primary_key=True, comment=\"User ID from Auth Service\")\n name = mapped_column(String, comment=\"User name: first, middle, last\")\n```\n\n## License\n\nThis project is licensed under the terms of the MIT license.\nSee the [LICENSE](LICENSE.md) file for the full license text.\n\n## Author\n\n- [Mike Fiedler](https://github.com/miketheman)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A flake8 plugin to detect issues with SQLAlchemy code",
"version": "0.2.0",
"project_urls": {
"Homepage": "https://github.com/miketheman/flake8-sqlalchemy",
"Repository": "https://github.com/miketheman/flake8-sqlalchemy"
},
"split_keywords": [
"flake8",
"lint",
"sqlalchemy"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6cf4207e32a090d2304561aec4b39ebcfb8b00bfc22d31ed1f70e91e598c7fd6",
"md5": "842882859313049bfcf8e243d816da83",
"sha256": "96c719d560f42857ef24fdb09b97a2e4acffbd40b6795f8bf26c01f2c109d50a"
},
"downloads": -1,
"filename": "flake8_sqlalchemy-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "842882859313049bfcf8e243d816da83",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8.1,<4.0.0",
"size": 8242,
"upload_time": "2023-09-03T23:19:09",
"upload_time_iso_8601": "2023-09-03T23:19:09.487099Z",
"url": "https://files.pythonhosted.org/packages/6c/f4/207e32a090d2304561aec4b39ebcfb8b00bfc22d31ed1f70e91e598c7fd6/flake8_sqlalchemy-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d8d6fe5646eb1c8e5f0260642128859195e6cc2ff7542356edeccebe90f63ef6",
"md5": "0bc46945ba2e84f3b893b03dd6b72e42",
"sha256": "0330865e8ea53c9da581283d960b91bf4716a467672d60a61433cbff202f884d"
},
"downloads": -1,
"filename": "flake8_sqlalchemy-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "0bc46945ba2e84f3b893b03dd6b72e42",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8.1,<4.0.0",
"size": 6432,
"upload_time": "2023-09-03T23:19:10",
"upload_time_iso_8601": "2023-09-03T23:19:10.909859Z",
"url": "https://files.pythonhosted.org/packages/d8/d6/fe5646eb1c8e5f0260642128859195e6cc2ff7542356edeccebe90f63ef6/flake8_sqlalchemy-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-03 23:19:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "miketheman",
"github_project": "flake8-sqlalchemy",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "flake8-sqlalchemy"
}