product:console
Interactive Python shell with the Flask app, database, and all feature models loaded.
Table of contents
Usage
splent product:console
Description
Opens an interactive Python REPL inside the Flask application context. All SQLAlchemy models from loaded features are auto-imported into the namespace, so you can query the database immediately without manual imports.
Uses IPython if installed, otherwise falls back to the standard Python REPL.
Auto-imported variables
| Variable | Description |
|---|---|
app |
The Flask application instance (context already pushed) |
db |
The SQLAlchemy instance (splent_framework.db.db) |
| Model classes | Every db.Model subclass: User, Note, UserProfile, … |
| Services | Any services registered in app.extensions['splent_services'] |
Example session
$ splent product:console
🐍 SPLENT console — my_first_app
app, db loaded.
Models: Note, User, UserProfile
Services: (none)
>>> app.config['SESSION_TYPE']
'redis'
>>> User.query.count()
42
>>> User.query.first()
<User admin>
>>> Note.query.filter_by(user_id=1).all()
[<Note 1>, <Note 2>]
>>> db.session.execute(db.text("SELECT COUNT(*) FROM user")).scalar()
42
>>> app.config['SQLALCHEMY_DATABASE_URI']
'mysql+pymysql://...'
When to use
| Scenario | Command |
|---|---|
| Quick data inspection or query | product:console |
| Run SQL directly | db:console (MariaDB shell) |
| Bash shell in the container | product:shell |
| View resolved config | product:config |
Requirements
- A product must be selected (
splent product:select). - The database must be reachable (models need the DB to resolve queries).
See also
db:console– MariaDB shell for raw SQLproduct:shell– bash shell inside the containerproduct:config– inspect resolved configuration