Skip to content

Commit

Permalink
💡 How to write tables w/o embeddings
Browse files Browse the repository at this point in the history
  • Loading branch information
redadmiral committed Jan 26, 2024
1 parent a54fb2a commit db455d7
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

.. highlight:: python

Welcome to brdata-rag-tools's documentation!
Expand Down Expand Up @@ -245,7 +244,37 @@ Since we ware using SQLAlchemy's Table classes, those tables are the exact repre
database and we will interact only through those Table classes with the content from the vector store.
Right now, we only have content in our tables and no embedding so far. The embedding is automatically computed when you
send your table to the database:
send your table to the database.
Write sqlalchemy tables to DB
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To create a normal table using SQLalchemy without embedding column follow the normal SQLalchemy procedure.
Import the Base class from the `databases` module, not from SQLAlchemy itself.
.. code-block:: python
# Import Base from databases module
from brdata_rag_tools.databases import Base
# Use Base as parent class for your table
class Person(Base):
__tablename__ = "person"
id: Mapped[str] = mapped_column(String, primary_key=True, unique=True)
name: Mapped[str] = mapped_column(String)
# Create tables
database.create_tables()
# Create a row
person = Person(
id = "123",
name = "John Doe"
)
# Set create_embeddings=False to write row to DB
database.write_rows([person], create_embeddings=False)
Querying the database
Expand Down

0 comments on commit db455d7

Please sign in to comment.