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
pip install twine
python setup.py sdist bdist_wheel
twine upload dist/*
rm -rf build dist opencopilot_db.egg-info
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-1.3.3.tar.gz
(3.3 kB
view hashes)
Built Distribution
Close
Hashes for opencopilot_db-1.3.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9bcff860ace448c53565cff1c3c3eddb96a7247fcfb379027b94bf1c737febf6 |
|
MD5 | 84b0c52f91d4c77977ef532b8632f4b8 |
|
BLAKE2b-256 | 6734c174925133094eaf23e028ec456886abb6efb76f5f092fb15f7751c82360 |