DataQuery is a Python package designed to simplify interactions with PostgreSQL databases. It leverages SQLAlchemy and pandas to provide an intuitive interface for retrieving, updating, inserting, and deleting data within a database. This package is ideal for data scientists and developers looking for a streamlined way to handle database operations.
- Easy retrieval of data into pandas DataFrames.
- Simplified update, insert, and delete operations.
- Customizable query capabilities with filtering criteria.
- Designed with best practices in database connections and session management.
Ensure you have Python 3.11 or higher installed. It's recommended to use a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
Install DataQuery using pip:
pip install dataquery
Or, if you're installing directly from the source:
git clone https://github.com/yourusername/querycraft.git
cd dataquery
pip install .
First, initialize the DataQuery object with your database credentials:
from dataquery import DataQuery
qc = DataQuery(host='localhost', port='5432', username='your_username', password='your_password',
database='your_database')
To retrieve data from a table:
df = qc.retrieve_data('table_name', {'column_name': 'value'})
To update data in a table:
from pandas import DataFrame
data = DataFrame({...}) # Your data to update
qc.update_data('table_name', ['column_to_match'], data)
Replace 'table_name'
, ['column_to_match']
, and data
with your specific table name, columns to match, and DataFrame containing the new data.
Contributions to DataQuery are welcome! If you're interested in contributing, please follow these guidelines:
- Create a New Branch: Create a new branch for your feature or fix.
- Commit Your Changes: Make your changes and commit them to your branch.
- Push to Your Brach: Push your branch on GitHub.
- Submit a Pull Request: Submit a pull request from your branch to the development branch.
Please ensure your code adheres to PEP 8 standards and include tests for new features or bug fixes.
DataQuery is licensed under the BSD 3-Clause License. See the LICENSE file for more details.