SQLconnect


NameSQLconnect JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/JustinFrizzell/SQLconnect
SummaryPackage to simplify connections to SQL databases.
upload_time2023-11-26 19:54:30
maintainer
docs_urlNone
authorJustin Frizzell
requires_python
license
keywords sql database connection configuration
VCS
bugtrack_url
requirements pandas sqlalchemy pyyaml pyodbc python-dotenv
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">
  <img alt="SQLconnect logo" src="https://raw.githubusercontent.com/JustinFrizzell/SQLconnect/main/images/logo.png"><br>
</div>

---

<p align="center">
<a href="https://pypi.org/project/SQLconnect/"><img alt="PyPI" src="https://img.shields.io/pypi/v/SQLconnect"></a>
<a href='https://sqlconnect.readthedocs.io/en/latest/?badge=latest'><img src='https://readthedocs.org/projects/sqlconnect/badge/?version=latest' alt='Documentation Status' /></a>
<a href="https://github.com/JustinFrizzell/SQLconnect/blob/main/LICENCE"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-purple.svg"></a>
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
</p>

**SQLconnect** is a Python package designed to simplify the process of connecting to SQL databases. It uses a `connections.yaml` file for database configuration and a `.env` file for secure credentials management. SQLconnect supports executing SQL from `.sql` files or Python strings, and retrieving data into pandas DataFrames. This package is particularly useful for data analysts and developers who need a straightforward way to interact with SQL databases.

## Features

- Allows easy configuration and management of database connections using a `connections.yaml` file.

- Supports the use of a `.env` file for secure storage of database credentials, enhancing security.

- Leverages SQLAlchemy for database connections, providing a robust and flexible framework for SQL operations.

- Enables executing SQL queries and directly retrieving the results into pandas DataFrames, facilitating easy data manipulation and analysis.

- Capable of handling multiple database connections, allowing users to switch between different databases as needed.

- Provides functionality to execute SQL queries either by reading from an external file or directly from a string.

## Installation

```bash
pip install SQLconnect
```

## Configuration

To use SQLconnect, create a `connections.yaml` file in the root of your project (or in your home directory) with the following example structure:

```yaml
connections:
  Database_PROD:
    sqlalchemy_driver: 'mssql+pyodbc'
    odbc_driver: 'SQL+Server'
    server: 'prod-server.database.com'
    database: 'ProdDB'
    username: '${DB_PROD_USERNAME}' # References DB_PROD_USERNAME in .env
    password: '${DB_PROD_PASSWORD}' # References DB_PROD_PASSWORD in .env
    options:
      - 'Trusted_Connection=No'
```

Also create a `.env` file in the root of your project (or in your home directory) with the following example structure:

```bash
# This file should be kept secure and not checked into version control (add to .gitignore)
# Production Database Credentials
DB_PROD_USERNAME=prodUser
DB_PROD_PASSWORD=prodPassword
```

Replace the example values with your actual database connection details.

## Usage

Here's a quick example to get you started:

```python
import SQLconnect as sc

# Set up a database connection, all configuration is handled with connections.yaml and .env
connection = sc.SQLconnector("Database_PROD")

# Assign the results of a query to a pandas DataFrame
df = connection.sql_to_df("your_query.sql")

# Explore the dataframe with pandas
print(df.describe())
```

## Documentation

Full documentation for SQLconnect can be found at https://sqlconnect.readthedocs.io/

## License

This project is licensed under the [MIT License](https://raw.githubusercontent.com/JustinFrizzell/SQLconnect/main/LICENCE).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/JustinFrizzell/SQLconnect",
    "name": "SQLconnect",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "SQL database connection configuration",
    "author": "Justin Frizzell",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/29/d8/2545f5c38ebcea4d626a8e5a8b1e2db67a634f10f4e76875f2858ce988be/SQLconnect-0.2.0.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\r\n  <img alt=\"SQLconnect logo\" src=\"https://raw.githubusercontent.com/JustinFrizzell/SQLconnect/main/images/logo.png\"><br>\r\n</div>\r\n\r\n---\r\n\r\n<p align=\"center\">\r\n<a href=\"https://pypi.org/project/SQLconnect/\"><img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/SQLconnect\"></a>\r\n<a href='https://sqlconnect.readthedocs.io/en/latest/?badge=latest'><img src='https://readthedocs.org/projects/sqlconnect/badge/?version=latest' alt='Documentation Status' /></a>\r\n<a href=\"https://github.com/JustinFrizzell/SQLconnect/blob/main/LICENCE\"><img alt=\"License: MIT\" src=\"https://img.shields.io/badge/License-MIT-purple.svg\"></a>\r\n<a href=\"https://github.com/psf/black\"><img alt=\"Code style: black\" src=\"https://img.shields.io/badge/code%20style-black-000000.svg\"></a>\r\n</p>\r\n\r\n**SQLconnect** is a Python package designed to simplify the process of connecting to SQL databases. It uses a `connections.yaml` file for database configuration and a `.env` file for secure credentials management. SQLconnect supports executing SQL from `.sql` files or Python strings, and retrieving data into pandas DataFrames. This package is particularly useful for data analysts and developers who need a straightforward way to interact with SQL databases.\r\n\r\n## Features\r\n\r\n- Allows easy configuration and management of database connections using a `connections.yaml` file.\r\n\r\n- Supports the use of a `.env` file for secure storage of database credentials, enhancing security.\r\n\r\n- Leverages SQLAlchemy for database connections, providing a robust and flexible framework for SQL operations.\r\n\r\n- Enables executing SQL queries and directly retrieving the results into pandas DataFrames, facilitating easy data manipulation and analysis.\r\n\r\n- Capable of handling multiple database connections, allowing users to switch between different databases as needed.\r\n\r\n- Provides functionality to execute SQL queries either by reading from an external file or directly from a string.\r\n\r\n## Installation\r\n\r\n```bash\r\npip install SQLconnect\r\n```\r\n\r\n## Configuration\r\n\r\nTo use SQLconnect, create a `connections.yaml` file in the root of your project (or in your home directory) with the following example structure:\r\n\r\n```yaml\r\nconnections:\r\n  Database_PROD:\r\n    sqlalchemy_driver: 'mssql+pyodbc'\r\n    odbc_driver: 'SQL+Server'\r\n    server: 'prod-server.database.com'\r\n    database: 'ProdDB'\r\n    username: '${DB_PROD_USERNAME}' # References DB_PROD_USERNAME in .env\r\n    password: '${DB_PROD_PASSWORD}' # References DB_PROD_PASSWORD in .env\r\n    options:\r\n      - 'Trusted_Connection=No'\r\n```\r\n\r\nAlso create a `.env` file in the root of your project (or in your home directory) with the following example structure:\r\n\r\n```bash\r\n# This file should be kept secure and not checked into version control (add to .gitignore)\r\n# Production Database Credentials\r\nDB_PROD_USERNAME=prodUser\r\nDB_PROD_PASSWORD=prodPassword\r\n```\r\n\r\nReplace the example values with your actual database connection details.\r\n\r\n## Usage\r\n\r\nHere's a quick example to get you started:\r\n\r\n```python\r\nimport SQLconnect as sc\r\n\r\n# Set up a database connection, all configuration is handled with connections.yaml and .env\r\nconnection = sc.SQLconnector(\"Database_PROD\")\r\n\r\n# Assign the results of a query to a pandas DataFrame\r\ndf = connection.sql_to_df(\"your_query.sql\")\r\n\r\n# Explore the dataframe with pandas\r\nprint(df.describe())\r\n```\r\n\r\n## Documentation\r\n\r\nFull documentation for SQLconnect can be found at https://sqlconnect.readthedocs.io/\r\n\r\n## License\r\n\r\nThis project is licensed under the [MIT License](https://raw.githubusercontent.com/JustinFrizzell/SQLconnect/main/LICENCE).\r\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Package to simplify connections to SQL databases.",
    "version": "0.2.0",
    "project_urls": {
        "Documentation": "https://sqlconnect.readthedocs.io/en/latest/",
        "Homepage": "https://github.com/JustinFrizzell/SQLconnect",
        "Source": "https://github.com/JustinFrizzell/SQLconnect"
    },
    "split_keywords": [
        "sql",
        "database",
        "connection",
        "configuration"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dabc33590fdedfc679e6067d7630021d22197ffb30bc21ab77053f46cd5b2d4a",
                "md5": "330b88630ea1ff3b88ac787c44d0d240",
                "sha256": "b60852a5e1d9bbb0b8a2cd41cc7a1f83da20dac2b0b5f0b2bef7f3d39c9bd675"
            },
            "downloads": -1,
            "filename": "SQLconnect-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "330b88630ea1ff3b88ac787c44d0d240",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 10091,
            "upload_time": "2023-11-26T19:54:26",
            "upload_time_iso_8601": "2023-11-26T19:54:26.969395Z",
            "url": "https://files.pythonhosted.org/packages/da/bc/33590fdedfc679e6067d7630021d22197ffb30bc21ab77053f46cd5b2d4a/SQLconnect-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "29d82545f5c38ebcea4d626a8e5a8b1e2db67a634f10f4e76875f2858ce988be",
                "md5": "3caaa99d8226bfb7a9d542119756ad20",
                "sha256": "3cc6e1e1f6a7fb7b1a826bbb41bbeda8a6575a424c69127933f63256057c61a3"
            },
            "downloads": -1,
            "filename": "SQLconnect-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "3caaa99d8226bfb7a9d542119756ad20",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8927,
            "upload_time": "2023-11-26T19:54:30",
            "upload_time_iso_8601": "2023-11-26T19:54:30.124248Z",
            "url": "https://files.pythonhosted.org/packages/29/d8/2545f5c38ebcea4d626a8e5a8b1e2db67a634f10f4e76875f2858ce988be/SQLconnect-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-26 19:54:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "JustinFrizzell",
    "github_project": "SQLconnect",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "pandas",
            "specs": []
        },
        {
            "name": "sqlalchemy",
            "specs": []
        },
        {
            "name": "pyyaml",
            "specs": []
        },
        {
            "name": "pyodbc",
            "specs": []
        },
        {
            "name": "python-dotenv",
            "specs": []
        }
    ],
    "lcname": "sqlconnect"
}
        
Elapsed time: 0.16000s