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:
- Fork the repository.
- Create a new branch for your feature or fix.
- Make your changes and ensure that tests pass.
- 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
Release history Release notifications | RSS feed
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-4.0.0.tar.gz
(3.4 kB
view hashes)
Built Distribution
Close
Hashes for opencopilot_db-4.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea6eba63e7f80bd3ac2eaec33cc85424309b49adad8d36e758ce56c1629b058d |
|
MD5 | 4327537e29a0888be720e4d004d0b62a |
|
BLAKE2b-256 | 2a7ac69b3a491cace9971d73bf7f8d5151b91a6144e0edf6744fb6f039cc8b9a |