Skip to main content

Flask extension that implements server-side sessions in PostgreSQL

Project description

FlaskPgSession

FlaskPgSession is a Flask extensions that implements server-side session support and stores the data in a PostgreSQL table.

It is inspired by Flask-Session but it's focused only on integration with PostgreSQL and therefore has fewer dependencies.

It is intended for people that are already using Flask with PostgreSQL and do not want to add another dependency to their app just for storing sessions (e.g. Redis).

Installation

You can install FlaskPgSession using pip

pip install flask-pg-session

Usage

Usage is pretty straightforward: just import FlaskPgSession and intialise it with your Flask app:

from flask import Flask
from flask_pg_session import FlaskPgSession

app = Flask("my-app")

# You can either pass the app as an argument to the constructor
FlaskPgSession(app)

# or initialise it separately
session = FlaskPgSession()
session.init_app(app)

Configuration

The extension can be configured via the Flask config file. The following options are available:

  • SQLALCHEMY_DATABASE_URI: The URI of the PostgreSQL database to use.
  • SESSION_PG_TABLE: The name of the table to store sessions in. Defaults to flask_sessions.
  • SESSION_PG_SCHEMA: The name of the schema to store sessions in. Defaults to public.
  • SESSION_KEY_PREFIX: The prefix to use for session IDs. Absent by default.
  • SESSION_USE_SIGNER: Whether to sign session IDs. Defaults to False.
  • SESSION_PERMANENT: Whether to set the permanent flag on sessions. Defaults to True.
  • SESSION_AUTODELETE_EXPIRED: Whether to automatically delete expired sessions. Defaults to True.
  • SESSION_PG_MAX_DB_CONN: The maximum number of database connections to use. Defaults to 10.

Contributions

Contributions are welcome! If you encounter any issues, have suggestions, or would like to contribute to FlaskPgSession, please feel free to submit a pull request or open an issue.

License

FlaskPgSession is open source and released under the MIT License.

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

flask_pg_session-0.1.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

flask_pg_session-0.1.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file flask_pg_session-0.1.0.tar.gz.

File metadata

  • Download URL: flask_pg_session-0.1.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.0 CPython/3.10.11 Linux/5.15.0-1037-azure

File hashes

Hashes for flask_pg_session-0.1.0.tar.gz
Algorithm Hash digest
SHA256 44aeb8ce933945facb06d31408ceea372b47c7b77123525bfb8c1e5e5a890725
MD5 42c32f1571945b95315c765af51f2cb9
BLAKE2b-256 45f7f53fc18800a20c228d0a9c1cd70592e09643d2ed537dea3ba81d847e0f20

See more details on using hashes here.

File details

Details for the file flask_pg_session-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: flask_pg_session-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.0 CPython/3.10.11 Linux/5.15.0-1037-azure

File hashes

Hashes for flask_pg_session-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 51f499fb315daa23c23b8761d8b598542f4d0f2210591ba9740686d638e33e48
MD5 6f7328f43824af85b4488b1a4e17ef3c
BLAKE2b-256 58922e30790d8ce7889df496bc2153753cd5a467746a1ef2fb9cc031769bd76c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page