🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

monkdb

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

monkdb

MonkDB Python Client to interact with MonkDB's database engine

1.0.5
PyPI
Maintainers
1

MonkDB

MonkDB Python Client Driver

Python Stable Version Last Updated

Introduction

This package is a MonkDB's Python SDK client library. It is compliant with PEP0249 to interact with database engines using Python's established goto practices.

Installation

One can use the regular pip to install monkdb client driver. It installs the latest package.

pip install monkdb

Or if you want to install a specific version using pip, please run the below command.

pip install monkdb==1.0.5

One can also use other python package managers. For example, below is the command to install with poetry. It installs the latest package

poetry add monkdb

Or if you want to add specific version of MonkDB using poetry, please run the below command.

poetry add monkdb@1.0.0

Usage Instructions

Connect to MonkDB

The first step in working with MonkDB is to establish a connection using the client instance. This is a prerequisite for performing downstream operations such as executing SQL statements, interacting with tables, and more.

from monkdb import client

try:
    connection = client.connect(
        f"http://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}", username=DB_USER
    )
    cursor = connection.cursor()
    print("✅ Database connection established successfully!")
except Exception as e:
    print(f"⚠️ Error connecting to the database: {e}")
    exit(1)

Sample Downstream Usage

Use the cursor that is connected to MonkDB in the previous step to execute SQL statements, close the connection, and perform other database operations.

In the example below, we are dropping the table if it exists:

# Drop table if exists
cursor.execute(f"DROP TABLE IF EXISTS {DB_SCHEMA}.{TABLE_NAME}")
print(f"Dropped {DB_SCHEMA}.{TABLE_NAME} table")

Closing the connection

If the connection is not needed anymore, please close the connection to MonkDB.

# Close connection
cursor.close()
connection.close()

Support

For enterprise support, please write to us at devs@monkdb.com.

Keywords

monkdb

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts