Cmotions DatabaseUtils
cmo_databaseutils is a Python library created by The Analytics Lab, which is powered by Cmotions. This library combines our most used functionality when it comes to connecting to databases from Python. Nothing fancy, but very useful for our consultants. Mostly since this package is used in other packages, which makes our workflow simpler and more efficient.
Since we love to share what we do, why not also do that with our packages, that is why we've decided to make (almost) all of our packages open source, this way we hope to give back to the community that brings us so much. Enjoy!
Installation
Install cmo_databaseutils using pip
pip install cmo-databaseutils
If you want to be able to use the tutorial notebook or the code below, you also need to install pydataset and dotenv using pip
pip install python-dotenv
pip install pydataset
Usage
import os
from pydataset import data
from dotenv import load_dotenv
from cmo_databaseutils import db_utils
load_dotenv()
df = data("iris")
# create a database connection to SQL Server using the credentials provided in a .env file
db_conn = db_utils(server=os.getenv("DB1_SERVER"), db=os.getenv("DB1_DATABASE"), server_name=os.getenv("DB1_SERVER_NAME"), usr=os.getenv("DB1_USERNAME"), pwd=os.getenv("DB1_PASSWORD"), driver=os.getenv("DB1_DRIVER"), port=os.getenv("DB1_PORT"))
# create a database connection to SQL Server using Windows credentials
db_conn = db_utils(server="localhost", db="localtemp")
# get an overview of all active schemas in the database
db_conn.list_all_active_schemas()
# get an overview of all tables in the database within the specified schemas
db_conn.list_all_tables(schema=['dbo'])
# load the data from an entire table
cars = db_conn.retrieve_table_from_sql(table="cars", schema="dbo")
# write a table to the SQL database, when possible the package will use BCP to optimize the efficiency of the process
db_conn.write_dataframe_to_sql(data=df, table="mynewtable", schema="dbo", replace_if_exists=False, index=False, dtype=None)
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.
License
GNU General Public License v3.0
Contributors
Jeanine Schoonemann
Contact us
Metadata
Release files for cmo-databaseutils 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cmo_databaseutils-0.0.2.tar.gz | 6.1 kB | Without provenance | Details for cmo_databaseutils-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cmo_databaseutils-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for cmo_databaseutils-0.0.2-py3-none-any.whl |
Total release size: 12.6 kB
Release files / cmo_databaseutils-0.0.2.tar.gz
| Download URL | cmo_databaseutils-0.0.2.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1615f1b0711a6b4ce65212753de9900f9ced0054f3b5977c95ca40b10a017fc9
|
|
BLAKE2b-256 checksum How to use checksums |
bde24485ecd4f317ca329f821a74f0a1212a9e242f5477e017afcc179ee0e016
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/5.1.0 pkginfo/1.9.6 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.65.0 CPython/3.9.1
|
Release files / cmo_databaseutils-0.0.2-py3-none-any.whl
| Download URL | cmo_databaseutils-0.0.2-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
90cd4621aa1bba592a5c0b655595e35971f85e97f71b0770971a7e146533db54
|
|
BLAKE2b-256 checksum How to use checksums |
67e1bc5d58297f0a42f08044a764064418c55057214c31d765c7ad51e7bd8e12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/5.1.0 pkginfo/1.9.6 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.65.0 CPython/3.9.1
|
Security for cmo-databaseutils 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.