Skip to main content

A tool for database operations with encryption and decryption, configurable table and column names, and additional CLI features.

Project description

DCheck Logo

dsqlenv-Env

dsqlenv is a SQL database operation tool designed to help developers quickly synchronize common variables, such as API keys, across different environments or hosts. All variables stored in the database are encrypted using AES for enhanced security.

Table of Contents

Features

  • Environment Variable Management: Search and update environment variables using keywords or regular expressions.
  • Database Operations: Perform basic SQL operations like get, insert, update, and delete records securely.
  • AES Encryption: All variables stored in the database are encrypted to ensure sensitive information is protected.

Installation

To install dsqlenv, follow these steps:

  1. Clone the repository:

    git clone https://gitee.com/iint/dsqlenv.git
    cd dsqlenv
    
  2. Install the required dependencies:

    pip install -r requirements.txt
    
  3. Create a .env file in the root directory and define the necessary environment variables, as explained in the next section.

or

pip install dsqlenv

Configuration

Before using dsqlenv, ensure that your environment variables contain the following database information:

DB_USER='<username>'  # Database username for authentication
DB_PASSWORD='<password>'  # Password for the database user
DB_NAME='xxx'  # The name of the database to connect to
DB_HOST='xxx'  # Hostname or IP address of the database server
DB_PORT='xxx'  # Port number for the database connection (default for MySQL is 3306)
AES_KEY='xxx'  # AES encryption key for securing sensitive data
TABLE_NAME='dagent_info'  # The name of the table to perform operations on
ID_COLUMN='name'  # The column name that acts as the unique identifier for records
INFO_COLUMN='data'  # The column name that stores the data you want to retrieve or update

Make sure to replace the placeholder values with your actual database credentials.

Quick Usage

To get started with dsqlenv, you can use the command-line interface (CLI) for quick database and environment variable operations.

Basic Commands

  • Get a Record:

    dsqlenv db --action get --id <Record ID>
    
  • Insert a Record:

    dsqlenv db --action insert --id <Record ID> --data <Record data>
    
  • Update a Record:

    dsqlenv db --action update --id <Record ID> --data <Record data>
    
  • Delete a Record:

    dsqlenv db --action delete --id <Record ID>
    

Python Usage Examples

You can also use the dsqlenv library directly in your Python code.

from dsqlenv.core import SQL
from dsqlenv.config import load_config

# Load configuration
config = load_config()
db = SQL(config)

# Insert a new record
db.insert_data("api_key", "your_api_key")

# Get a record by ID
data = db.get_data_by_id("api_key")
print(data)

# Update a record
db.update_data("api_key", "new_api_key")

# Delete a record
db.delete_data("api_key")

CLI Usage Examples

Here are some examples of how to use the CLI effectively:

  • Search for Environment Variables:

    dsqlenv search-env --keyword SECRET
    
  • Update an Environment Variable:

    dsqlenv update-env --key API_KEY --value new_value
    
  • Search using Regular Expressions:

    dsqlenv re search '^SECRET'
    
  • Update using Regular Expressions:

    dsqlenv re update '^API_' 'new_value'
    

License

This project is licensed under the MIT License. See the LICENSE file for details.

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

dsqlenv-1.0.2.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

dsqlenv-1.0.2-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file dsqlenv-1.0.2.tar.gz.

File metadata

  • Download URL: dsqlenv-1.0.2.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.9

File hashes

Hashes for dsqlenv-1.0.2.tar.gz
Algorithm Hash digest
SHA256 9751b8d51bc9b1fda7d64e272636eff8fb45ce78e078bf1d94bfb0b365cd3125
MD5 2325aecead4024638c0e2918693fc871
BLAKE2b-256 8e0f7d7196f0b7b09f69c5d0b1befcabeb68ae5b92d238949f192b3f3ecd8af8

See more details on using hashes here.

File details

Details for the file dsqlenv-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: dsqlenv-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.9

File hashes

Hashes for dsqlenv-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3db18889264403322ed5b2b5dee038fa5241522e2161d9b4394e13549ac70a42
MD5 bf4492565f601960aa7afcd440fd429a
BLAKE2b-256 7d9227ddc42c3d221db7b0aa5dbae362ac4651ee00224a60dd8fc2b7aa77561d

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