Skip to main content

Database schemas for OpenCopilot microservices and plugins

Project description

# opencopilot_db

`opencopilot_db` is a Python library that provides database schemas common for opencopilot main app and workers application. It defines SQLAlchemy models for working with databases, making it easy to integrate and manage your database operations.

## Installation

You can install `opencopilot_db` using pip:

```bash
pip install opencopilot_db

Usage

To create pool of connections use the following

from shared.models import create_database_schema
from dotenv import load_dotenv

import os
load_dotenv("../llm-server/.env")

create_database_schema()

Importing the Models

from opencopilot_db.models import PdfDataSource, Chatbot

Creating and Managing Database Records

# Create a PdfDataSource
pdf_data_source = PdfDataSource(chatbot_id=1, files=['file1.pdf', 'file2.pdf'], folder_name='pdf_folder')
session.add(pdf_data_source)
session.commit()

# Query PdfDataSources
pdf_data_sources = session.query(PdfDataSource).all()
for pdf_data_source in pdf_data_sources:
    print(f"PdfDataSource ID: {pdf_data_source.id}, Chatbot ID: {pdf_data_source.chatbot_id}, Files: {pdf_data_source.files}")

Working with the Chatbot Model

# Create a Chatbot
chatbot = Chatbot(name="My Chatbot", website="https://example.com")
session.add(chatbot)
session.commit()

# Query Chatbots
chatbots = session.query(Chatbot).all()
for chatbot in chatbots:
    print(f"Chatbot ID: {chatbot.id}, Name: {chatbot.name}, Website: {chatbot.website}")

Contributing

If you'd like to contribute to opencopilot_db, please follow these guidelines:

  1. Fork the repository.
  2. Create a new branch for your feature or fix.
  3. Make your changes and ensure that tests pass.
  4. Submit a pull request to the main branch of the repository.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Special thanks to the SQLAlchemy project for making it easy to work with databases in Python.

Publish guide

Publishing Your Library

Increment the version of the library in setup.py Use the publish script publish.sh to publish the library

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

opencopilot_db-5.0.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

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

opencopilot_db-5.0.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file opencopilot_db-5.0.0.tar.gz.

File metadata

  • Download URL: opencopilot_db-5.0.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for opencopilot_db-5.0.0.tar.gz
Algorithm Hash digest
SHA256 4227747d8f1d16224baa8d38b993182fcb937d912e15da57fec70c4ae8422c27
MD5 1ce75a53ab0ed1c6d5fd83b8d5c515c0
BLAKE2b-256 972edbd75035a07e02241f79d90d3f9315812b451c13c3a50e010d9feece3641

See more details on using hashes here.

File details

Details for the file opencopilot_db-5.0.0-py3-none-any.whl.

File metadata

  • Download URL: opencopilot_db-5.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for opencopilot_db-5.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3bfa2f5934ec380a0de571c3192552b8412ef90f6635789c0c00316beb744487
MD5 8fee9bea7079fba2050bdfcbbd3a5163
BLAKE2b-256 8007ec609ab52e470771df8742ef08b1fd89806ad4fbf0c11e2fd80acc6f077b

See more details on using hashes here.

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