Skip to main content

Wrappers for connecting to data systems

Project description

THIS PROJECT IS IN ALPHA AND MAY INTRODUCE BREAKING CHANGES

Contributors Forks Stargazers Issues MIT License


Logo

Cnxns

A lightweight, extensible library that simplifies interaction with heterogeneous data systems. It standardises connections, authentication, and data transfer into consistent, Pandas‑friendly workflows, enabling seamless integration across databases and APIs without the overhead of system‑specific code.
Report Bug · Request Feature

Table of Contents
  1. About the Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Acknowledgments

About the Project

This library provides a unified interface for interacting with diverse data systems, eliminating the need to manage the intricacies of individual platforms. By abstracting connection handling, authentication, data retrieval, and writing operations into simple, consistent functions, it enables developers and data engineers to focus on analysis and integration rather than boilerplate code.

Whether working with traditional databases or modern API endpoints, the library standardises workflows into familiar patterns such as reading into Pandas DataFrames, chunked processing for large datasets, and seamless write‑back operations. Built with extensibility in mind, new data systems can be added without disrupting existing usage, ensuring the library evolves alongside your environment.

Designed for clarity, maintainability, and scalability, this library is a practical foundation for projects that demand reliable access to heterogeneous data sources.

(back to top)

Getting Started

pip install cnxns

(back to top)

Usage

dbms

The dbms module provides a streamlined interface for interacting with SQL-based data systems through SQLAlchemy. It abstracts connection setup, data ingestion, and write-back operations into concise, reusable functions that integrate seamlessly with Pandas. With built-in support for chunked reading and writing, it enables efficient handling of large datasets while maintaining clarity and consistency across varied database backends.

Supports

  • Microsoft SQL Server
  • MySQL/MariaDB

Pre-requisites

  • Either:
    • ODBC Driver X for SQL Server (tested with 18)
    • MySQL ODBC X driver (tested with 9.4)

Example

from cnxns import dbms as db

e = db.dbms_cnxn(
    dbms = "mssql",
    server = "localhost",
    uid = "sa",
    pwd = "YourStrong@Passw0rd",
    database = "dev",
)

df = db.dbms_reader(
    e,
    query = "SELECT TOP(1000) * FROM myAwesomeTable",
)

print(df)

for chunk in db.dbms_read_chunks(
    e,
    table_name = "myAwesomeTable",
    chunksize = 1000,
):

  db.dbms_writer(
      e,
      df,
      "myAwesomeTableSnapshot",
      if_exists="append",
  )

(back to top)

m365

The m365 module abstracts authentication and data access workflows for Microsoft 365 APIs, streamlining interactions with services like Graph and Dataverse. It handles token generation via MSAL and Azure AD app registration, enabling secure, reusable access patterns. With built-in support for chunked queries and JSON response handling, it simplifies integration into data pipelines and analytical workflows while maintaining flexibility across varied Microsoft 365 endpoints.

Supports

  • Dataverse REST API
  • Microsoft 365 Graph API

Pre-requisites

  • An application registered in Azure Active Directory. You will need:
    • Tennant ID
    • Client ID
    • Client Secret

Example

from cnxns.api import m365

result = m365.query_api(
    client_id="A123",
    client_secret="B234",
    tenant_id="C345",
    base_url="https://myamazingcompany.crm.dynamics.com",
    api_url="api/data/v9.0",
    query="/accounts?$select=accountid,versionnumber",
    chunksize=1000,
)

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Acknowledgments

(back to top)

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

cnxns-0.0.3.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

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

cnxns-0.0.3-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file cnxns-0.0.3.tar.gz.

File metadata

  • Download URL: cnxns-0.0.3.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cnxns-0.0.3.tar.gz
Algorithm Hash digest
SHA256 39fd9498363677aa78089643e4e6ee653893c4a7b9a505f3a44ee021a8d5cdb8
MD5 24625ebb1ad744f470efa091dff16dca
BLAKE2b-256 6b3fc2740b4f690ad81547837f6726b9eec9d3966e9affcf0d0557b60fffafb5

See more details on using hashes here.

Provenance

The following attestation bundles were made for cnxns-0.0.3.tar.gz:

Publisher: python-publish.yml on philipbudden/cnxns

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cnxns-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: cnxns-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cnxns-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4e674a050131b9af498750429c8b42fc07a1fa24c28c7ce07c0ce0d36d66e3a8
MD5 c423f127a5e424cd91b03827e5e3267d
BLAKE2b-256 7482789881552d1b67f0827713536d757dbb9d1829f032fc7fa85a519bbdc34d

See more details on using hashes here.

Provenance

The following attestation bundles were made for cnxns-0.0.3-py3-none-any.whl:

Publisher: python-publish.yml on philipbudden/cnxns

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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