Create Views and Materialized Views with SqlAlchemy
Project description
SQL Alchemy Plus
This package provide additional package definition for SqlAlchemy that are specific for PostgreSQL and other database.
Here are the currently supported features (database supported):
- View (PostgreSQL)
- Materialized View (PostgreSQL)
Installation
Install SQL Alchemy Plus using pip
pip install sqlalchemyplus
Quick start
Define a View or a Materialized View programmatically
from sqlalchemy import Table, select, Column, MetaData, Integer, String
from sqlalchemyplus import View
metadata = MetaData()
table = Table('mytable',
metadata,
Column('key', Integer),
Column('value', String))
select_table = table.select()
view = View(
'myview',
metadata,
select_table
)
Create and drop a view
from sqlalchemy import create_engine
from sqlalchemyplus import CreateView, DropView
engine = create_engine("postgresql://example:example@localhost:5432/mydatabase")
view = View(
'myview',
metadata,
select_table
)
# Execute 'CREATE VIEW myview AS (...)'
engine.execute(CreateView(view))
# Execute 'DROP VIEW myview'
engine.execute(CreateView(view))
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sqlalchemy-plus-0.2.0.tar.gz
(4.7 kB
view hashes)
Built Distribution
Close
Hashes for sqlalchemy_plus-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f8d876c766e728e01c500fd6f2161226aec9c8d88fa2ce422f2fff39d29cc25 |
|
MD5 | e7bfee21142e8b119ab2bb71bf0b981b |
|
BLAKE2b-256 | 513ad96cfa08e2cb6640bd51a62d1d659967c735ee73b8e5aecb500d52cd0d43 |