Skip to main content

A python library for seamless data extraction, storage, and SQL-based analysis using pandas and SQLite.

Project description

hamana

Illustrations by @gaiaparte

Supported Python Versions PyPI version Tests Coverage Statistics License


Documentation: https://zazza123.github.io/hamana


hamana (Hamster Analysis) is a Python library designed to simplify data analysis by combining the practicality of pandas and SQL in an open-source environment. This library was born from the experience of working in a large company where tools like SAS were often used as "shortcuts" to perform SQL queries across different data sources, without fully leveraging their potential. With the goal of providing a free and accessible alternative, hamana replicates these functionalities in an open-source context.

Why Choose hamana?

Hamana Explain
  • Support for Multiple Data Sources: Connect to various data sources such as relational databases, CSV files, mainframes, and more.
  • SQLite Integration: Save data locally in an SQLite database, either as a file or in memory.
  • SQL + pandas: Combine the power of SQL with the flexibility of pandas for advanced analysis.
  • Open Source: Available to everyone without licensing costs.
  • Why "Hamster"?: Because hamsters are awesome!

Key Features

1. Data Extraction

Hamana allows you to extract data from a variety of sources:

  • Relational databases (SQLite, Oracle, etc.)
  • CSV, Excel, JSON, and other common file formats
  • Legacy sources like mainframes

Extractions are automatically saved as pandas DataFrames, making data manipulation simple and intuitive.

2. SQLite Storage

Each extraction can be saved in an SQLite database, enabling you to:

  • Store data locally for future use
  • Perform SQL queries to combine extractions from different sources

3. Data Analysis

With Hamana, you can:

  • Use pandas to quickly and flexibly manipulate data
  • Write SQL queries directly on datasets stored in SQLite
  • Integrate SQL and pandas into a single workflow for advanced analysis

Installation

Hamana is available on PyPI, and you can install it easily with pip:

pip install hamana

Usage Example

Here is an example of how to use Hamana to connect to a data source, extract information, and combine it with another table:

import hamana as hm

# connect hamana database
hm.connect()

# connect to Oracle database
oracle_db = hm.connector.db.Oracle.new(
    host = "localhost",
    port = 1521,
    user = "user",
    password = "password"
)

# define, execute and store a query
orders = hm.Query("SELECT * FROM orders")
oracle_db.to_sqlite(orders, table_name = "orders")

# load a CSV file and store it in SQLite
customers = hm.connector.file.CSV("customers.csv")
customers.to_sqlite(table_name = "customers")

# combine the two tables using SQL
customers_orders = hm.execute("""
    SELECT
          c.customer_name
        , o.order_date
        , o.total
    FROM customers c
    JOIN orders o ON
        c.customer_id = o.customer_id"""
)

# use `pandas` for further analysis
print(customers_orders.result.head())

# close connection
hm.disconnect()

How to Contribute

If you want to contribute to Hamana:

  1. Fork the repository.

  2. Create a branch for your changes:

    git checkout -b feature/your-feature-name
    
  3. Submit a pull request describing the changes.

All contributions are welcome!

License

This project is distributed under the BSD 3-Clause "New" or "Revised" license.

Contact

For questions or suggestions, you can open an Issue on GitHub or contact me directly.


Thank you for choosing Hamana!

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

hamana-1.0.1.tar.gz (2.8 MB view details)

Uploaded Source

Built Distribution

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

hamana-1.0.1-py3-none-any.whl (37.0 kB view details)

Uploaded Python 3

File details

Details for the file hamana-1.0.1.tar.gz.

File metadata

  • Download URL: hamana-1.0.1.tar.gz
  • Upload date:
  • Size: 2.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.11

File hashes

Hashes for hamana-1.0.1.tar.gz
Algorithm Hash digest
SHA256 44e165b0574bdc4cae8dea88c354e19a2489abfee33fa72eb4651367987ec0ad
MD5 3c3eb7860a799ce4593b10af0f06567e
BLAKE2b-256 3ced45e2086d982644d8c8d6b0df3811106e698be76c0cec74685501a15a1ed1

See more details on using hashes here.

File details

Details for the file hamana-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: hamana-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 37.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.11

File hashes

Hashes for hamana-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 52a11a8fe29a8bacf81b63cd5327625eebfd464460b05c827be4c042c211f4b3
MD5 fc49c4607c2bea758100447dba9ffb11
BLAKE2b-256 be8655bff7a64874cf577f9712fdb1daad8c82dabcce92130c698e58b676305d

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