Skip to main content

SQuiRL

    SQuiRL is a Python library for interacting with any type of data storage structure, including filesystems, databases, caches, and various text file types. It provides a unified API to read, write, query, and manage data across diverse storage systems, abstracting away the complexities of different backends for seamless integration in applications.
    
    ## Features
    
    - **Unified Interface**: Interact with filesystems (local, remote), databases (SQL, NoSQL), caches (in-memory, distributed), and text files (CSV, JSON, XML, etc.) through a consistent Pythonic API.
    - **Extensible Backends**: Support for multiple storage types with pluggable adapters; easily add custom backends.
    - **Data Operations**: Perform CRUD (Create, Read, Update, Delete) operations, queries, and transformations across storage structures.
    - **Configuration-Driven**: Use YAML or Python configs to define storage connections and behaviors.
    - **Cross-Platform Compatibility**: Works on Windows, macOS, and Linux.
    - **Error Handling and Logging**: Built-in mechanisms for robust error management and detailed logging.
    - **Performance Optimizations**: Efficient handling for large datasets, batch operations, and caching layers.
    
    ## Installation
    
    You can install SQuiRL via pip:
    
    ```bash
    pip install squirrl
    ```
    
    Alternatively, clone the repository and install from source:
    
    ```bash
    git clone https://github.com/<USER_OR_ORG>/squirrl.git
    cd squirrl
    pip install -e .
    ```
    
    ### Requirements
    
    - Python 3.<MIN_VERSION> or higher
    - Dependencies: pyyaml, <DB_LIB>, <CACHE_LIB>, <FILE_LIB> (automatically installed via pip where applicable)
    
    ## Quick Start
    
    Import the module, configure a storage backend, and perform operations:
    
    ```python
    import squirrl
    
    # Load configuration for a storage type
    config = squirrl.load_config('path/to/filesystem.yaml')
    
    # Initialize the storage interface
    storage = squirrl.Storage(config)
    
    # Write data
    storage.write('key/path', 'Hello, World!')
    
    # Read data
    data = storage.read('key/path')
    print(data)  # Output: Hello, World!
    ```
    
    ## Usage
    
    ### Loading Configurations
    
    SQuiRL relies on YAML files to define storage backends. A sample YAML for a database might look like:
    
    ```yaml
    storage_type: database
    backend: <DB_LIB>
    connection:
      host: localhost
      port: 5432
      user: <USER>
      password: <PASS>
      db_name: mydb
    operations:
      query: sql_query_method
      insert: insert_method
    ```
    
    Use `squirrl.load_config(yaml_path)` to parse and validate the config.
    
    ### Interacting with Storage
    
    ```python
    # Initialize with config
    config = squirrl.load_config('cache.yaml')
    cache = squirrl.Storage(config)
    
    # Set and get cache values
    cache.set('user_data', {'id': 1, 'name': 'Alice'})
    value = cache.get('user_data')
    
    # Delete
    cache.delete('user_data')
    ```
    
    ### Handling Different Storage Types
    
    - **Filesystems**: Local directories, S3 buckets, etc.
    - **Databases**: SQLite, PostgreSQL, MongoDB, etc.
    - **Caches**: Redis, Memcached, in-memory dicts.
    - **Text Files**: Read/write CSV, JSON, YAML, XML with parsing support.
    
    ```python
    # Example with text file
    config = squirrl.load_config('json_file.yaml')
    file_storage = squirrl.Storage(config)
    data = file_storage.read('data.json')  # Returns parsed dict
    file_storage.write('data.json', {'key': 'value'})
    ```
    
    ## Examples
    
    ### Example 1: Database Querying
    
    ```python
    import squirrl
    
    config = squirrl.load_config('database.yaml')
    db = squirrl.Storage(config)
    db.connect()
    
    # Execute query
    results = db.query('SELECT * FROM users WHERE active = ?', (True,))
    
    # Insert data
    db.insert('INSERT INTO users (name, active) VALUES (?, ?)', ('Bob', True))
    
    db.close()
    ```
    
    ### Example 2: Multi-Storage Workflow
    
    ```python
    import squirrl
    
    configs = ['filesystem.yaml', 'cache.yaml']
    storages = [squirrl.Storage(squirrl.load_config(cfg)) for cfg in configs]
    
    # Read from filesystem, cache it
    data = storages[0].read('file.txt')
    storages[1].set('cached_file', data)
    
    # Retrieve from cache
    cached_data = storages[1].get('cached_file')
    ```
    
    ## Configuration Guide
    
    Each YAML config must include:
    
    - `storage_type`: String identifier (e.g., 'filesystem', 'database', 'cache', 'textfile')
    - `backend`: The underlying library or driver (e.g., '<FS_LIB>', '<DB_LIB>')
    - `connection`: Dictionary of connection parameters
    - `operations`: Mapping of SQuiRL methods to backend-specific calls
    
    For advanced customization, refer to the [docs/config-reference.md](docs/config-reference.md).
    
    ## Contributing
    
    Contributions are welcome! Please follow these steps:
    
    1. Fork the repository.
    2. Create a feature branch (`git checkout -b feature/<FEATURE_NAME>`).
    3. Commit your changes (`git commit -am 'Add some feature'`).
    4. Push to the branch (`git push origin feature/<FEATURE_NAME>`).
    5. Open a Pull Request.
    
    See [CONTRIBUTING.md](CONTRIBUTING.md) for more details.
    
    ## License
    
    This project is licensed under the <LICENSE_TYPE> License - see the [LICENSE](LICENSE) file for details.
    
    ## Acknowledgments
    
    - Built with inspiration from open-source data handling communities.
    - Thanks to contributors of underlying libraries like <DB_LIB>, <CACHE_LIB>, <FILE_LIB>.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

squirl-0.0.1-cp312-cp312-manylinux_2_39_x86_64.whl (187.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.39+ x86-64

File details

Details for the file squirl-0.0.1-cp312-cp312-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for squirl-0.0.1-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 c46f50e48523c4c94667115c80708c80c12538351c5ccd7182e018af286d0c71
MD5 36b3de3d7bda9a8eb05f1519400d3fb8
BLAKE2b-256 3492f13996539fb71bda084d60204ecae49b4d09af25d0f43023f86caf0a9881

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 file

0.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page