skillfed

sqlalchemy-views

Adds CreateView and DropView constructs to SQLAlchemy

sqlalchemy-views v0.3.2 150.8K downloads/30d#10,955 on PyPI58
Permissive license Active released

What it is and what it does

sqlalchemy-views extends SQLAlchemy with two new SQL constructs—CreateView and DropView—that let you define and manipulate database views using SQLAlchemy's expression API instead of raw SQL strings. It wraps the view definition (typically a SELECT statement) and compiles it to the appropriate CREATE VIEW or DROP VIEW SQL for execution.

The package is designed for developers who want to manage views programmatically within SQLAlchemy applications, supporting common options like OR REPLACE, IF EXISTS, CASCADE, and dialect-specific view options. It relies entirely on sqlalchemy as its runtime dependency and has remained stable because it builds on SQLAlchemy's core, stable APIs rather than internal details.

Use it for:

  • Define database views in Python code alongside table definitions for schema migrations and setup scripts
  • Conditionally create or replace views with OR REPLACE or IF EXISTS flags in application initialization
  • Drop views safely with CASCADE when cleaning up or resetting a database schema
  • Introspect existing views using SQLAlchemy's Table object and regenerate their definitions programmatically

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Adds CreateView and DropView SQL constructs to SQLAlchemy, enabling programmatic creation and removal of database views through SQLAlchemy's expression language.

Yes, if you need to manage database views within SQLAlchemy code. The package is small, stable, and has no known vulnerabilities. Install friction is minimal (one dependency). The main caveat is that it supports only a core subset of SQL dialects—if your database uses nonstandard CREATE/DROP VIEW syntax, you may need to fall back to raw SQL or check whether your dialect is covered.

Install

sqlalchemy-views on PyPI

pip

pip install sqlalchemy-views

uv

uv add sqlalchemy-views

poetry

poetry add sqlalchemy-views

Installing sqlalchemy-views

Before you install

Low friction install with a single runtime dependency on sqlalchemy. The codebase is small and stable; maintenance has been minimal since early 2023 because it relies on stable SQLAlchemy APIs. Repository remains active with recent commits.

License in practice

Licensed under MIT (permissive), so you can use, modify, and distribute this package freely with minimal restrictions.

Quickstart

pip install sqlalchemy-views

from sqlalchemy import Table, MetaData
from sqlalchemy.sql import text
from sqlalchemy_views import CreateView, DropView

view = Table('my_view', MetaData())
definition = text("SELECT * FROM my_table")
create_view = CreateView(view, definition)
print(str(create_view.compile()).strip())

Verify before relying

  • Whether the package supports all major SQL dialects or only a core subset of CREATE/DROP VIEW syntax
  • Current compatibility with SQLAlchemy 2.0 beyond the stated 'early 2023' snapshot

Package facts

License not declared (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies 1 — sqlalchemy
Maintenance actively maintained — 1,273 days since the last release
Last repo commit
First released
Downloads 150,750/month — #10,955 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: sqlalchemy_views-0.3.2-py3-none-any.whl

Development Status :: 4 - BetaEnvironment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: Python :: 2.6Programming Language :: Python :: 2.7Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: PyPyProgramming Language :: SQLTopic :: DatabaseTopic :: Database :: Database Engines/ServersTopic :: Software Development :: Libraries :: Python Modules

Tags

sqlalchemy view creationdatabase view managementcreate drop view sqlalchemysql view constructssqlalchemy database views
sqlalchemy-extensionschema-management

More Python Modules packages