Configuration
Settings for connections, theming, and logging.
When initializing a new Preswald project with preswald init
, a default preswald.toml
file is created. This file defines core settings for the app, including logging, theming, and data connections. Data connections can include databases like PostgreSQL or local CSV files.
Default Configuration (preswald.toml
)
The following is the default structure of preswald.toml
created during initialization:
Example preswald.toml
Configuration Sections
[project]
title
: Name of the app displayed in the interface.version
: Version of the app.port
: Port the app runs on (default is8501
).
[branding]
name
: Displayed name of the app.logo
: Path to the logo file (relative to the project directory).favicon
: Path to the favicon file.primaryColor
: The primary UI color, specified as a CSS-compatible color (e.g.,#3498db
).
Connecting to Data Sources
PostgreSQL Example: [data.postgres]
type
: Use"postgres"
for PostgreSQL.host
: Hostname or IP of the database server.port
: Port number for the database (default is5432
).dbname
: Name of the database.user
: Username for database access.
CSV Example: [data.csv]
You can use a local CSV file as a data source by defining it in preswald.toml
.
Fields:
type
: Use"csv"
to specify that this connection refers to a CSV file.path
: Relative or absolute path to the CSV file.delimiter
: The character used to separate values (e.g.,,
or;
).header
: Set totrue
if the CSV file contains a header row, otherwisefalse
.
Example CSV Connection:
If the CSV file is located in a subdirectory, make sure the path
is correct relative to the root directory.
Logging Configuration
The [logging]
section allows you to control the verbosity and format of logs generated by the app.
Fields:
level
: Minimum severity level for log messages. Options:DEBUG
: Logs detailed debugging information.INFO
: Logs general app activity.WARNING
: Logs warnings or potential issues.ERROR
: Logs critical errors.CRITICAL
: Logs only severe issues that cause immediate failure.
format
: Specifies the format of the log messages. Common placeholders:%(asctime)s
: Timestamp of the log entry.%(name)s
: Name of the logger.%(levelname)s
: Severity level of the log.%(message)s
: Log message content.
Example Logging Setup:
This configuration generates detailed logs, including timestamps, logger names, and log messages.
Was this page helpful?