Skip to main content

A python wrapper around [vivadb](https://github.com/AstraBert/vivadb)

Project description

vivadb-py

A python wrapper around vivadb.

Installation

Install through pip (or your favorite dependency manager):

pip install vivadb-py

Commands

The package comes bundled with the vivadb executable and has all its subcommands.

config - Database Configuration

Configure your PostgreSQL connection settings and save them to environment files.

vivadb config [OPTIONS]

Options:

  • --host - PostgreSQL host (default: localhost)
  • --port - PostgreSQL port (default: 5432)
  • --user - PostgreSQL username
  • --password - Password (not recommended for production)
  • --password-stdin - Input password securely from stdin
  • --dbname - Database name
  • --prod - Write to production environment file
  • -h, --help - Show help for this command

Examples:

# Configure development database with secure password input
vivadb config --host=localhost --port=5432 --user=myuser --dbname=postgres --password-stdin

# Configure production database
vivadb config --host=prod-server --use= prod_user --dbname=production_db --prod --password-stdin

exec - Execute SQL Queries

Execute SQL queries with production awareness and optional safety checks.

vivadb exec [OPTIONS]

Options:

  • -q, --query - SQL query to execute
  • -s, --safe - Execute only safe queries
  • -p, --prod - Run in production environment
  • -h, --help - Show help for this command

Examples:

# Execute a safe query in development
vivadb exec --query="SELECT * FROM users LIMIT 10;" --safe

# Execute query in production (use with caution)
vivadb exec --query="UPDATE users SET status = 'active' WHERE created_at > '2024-01-01';" --prod

new - Create New Project

Create a new project with database integration and optional Docker setup.

vivadb new [OPTIONS]

Options:

  • --host - PostgreSQL host
  • --port - PostgreSQL port
  • --user - PostgreSQL username
  • --password - Password (not recommended)
  • --password-stdin - Input password securely from stdin
  • --dbname - Database name
  • --prod - Configure for production
  • --docker - Create Docker Compose configuration
  • -h, --help - Show help for this command

Examples:

# Create new project with Docker setup
vivadb new --project-name=hello_world --docker --host=localhost --port=5432 --user=myuser --dbname=postgres --password-stdin

migrate - Database Migrations

Update your database schema in a production-aware manner.

vivadb migrate [OPTIONS]

Options:

  • --prod - Run migration in production environment
  • -h, --help - Show help for this command

Examples:

# Run migrations in development
vivadb migrate

# Run migrations in production
vivadb migrate --prod

Environment Files

vivadb manages separate environment files for development and production:

  • Development: .vivadb/.env.local
  • Production: .vivadb/.env

This separation helps prevent accidental operations on production databases during development.

Security Best Practices

  1. Use --password-stdin: Always use the --password-stdin flag instead of --password to avoid exposing credentials in your shell history.

  2. Production flag: Always use the --prod flag when working with production databases to ensure proper environment separation.

  3. Safe queries: Use the --safe and/or --prod flag with the exec command when possible to enable additional safety checks.

Project Structure

When using vivadb new, the tool creates a project structure optimized for database-driven applications, including:

  • Environment configuration files
  • Optional Docker Compose setup for local PostgreSQL
  • Project scaffolding with database integration

Here is how a project would look like:

.
├── .gitignore
├── .vivadb
│   ├── .env.local
│   └── compose.yaml
├── README.md
└── schema.v.sql

Contributing

Contributions are more than welcome! Find the contribution guidelines here

License

This project is distributed under an MIT License

Support

For issues and questions, please create an issue in the repository.

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

vivadb_py-0.1.1a0.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vivadb_py-0.1.1a0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file vivadb_py-0.1.1a0.tar.gz.

File metadata

  • Download URL: vivadb_py-0.1.1a0.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.22

File hashes

Hashes for vivadb_py-0.1.1a0.tar.gz
Algorithm Hash digest
SHA256 816ae1dc5825611e01850de23a07b7f69170dbc4d0fb9000a8cd096aaeb16e7e
MD5 5436df51fa83a40298ba8ef728f9cc84
BLAKE2b-256 91f46306d35f4f9919387c5a78b20eb5eb369acadaf437d7f0a84eb516b03cb7

See more details on using hashes here.

File details

Details for the file vivadb_py-0.1.1a0-py3-none-any.whl.

File metadata

File hashes

Hashes for vivadb_py-0.1.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 506920cdbd85e83f04af8c79c77fb34cadd97562f157838009cc4fe16055844e
MD5 6e9bb890d16ce75b31ebe4c4815f8e48
BLAKE2b-256 ab2e8aa70289e0760ebe0439903c468fae16e9d4a6591417a0aa52979b93581c

See more details on using hashes here.

Supported by

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