New Component: Streamlit Xata Database Connection: Empower Your Projects with a Database for Free

Streamlit Xata Data Base Connection


:rocket: Introducing st-xatadb-connection Package! :rocket:

To further enhance the synergy between Xata and Streamlit, I’ve created the st_xatadb_connection package. This package provides a seamless bridge between the two tools, making it incredibly easy to connect your Streamlit application to your Xata database.The st_xatadb_connection package takes care of all the heavy lifting, allowing you to focus on building your application’s functionality.

Why Use st-xatadb-connection :thinking:?

  1. :arrows_counterclockwise: Seamless Integration:

    • Effortlessly connect and interact with your Xata database using intuitive methods.
  2. :hammer_and_wrench: Comprehensive Functionality:

    • Enjoy a rich set of functions, from basic queries to advanced AI interactions and file handling.
  3. :lock: Secure Credentials Handling:

    • Safely manage your Xata API key and database URL using Streamlit’s secrets manager or environment variables.
  4. :rocket: Boosted Productivity:

    • Streamline your workflow with efficient data manipulation and advanced search capabilities.
  5. :globe_with_meridians: Real-time Connectivity:

    • Experience real-time interactions with your Xata database, keeping your data up-to-date.
  6. :brain: AI Integration Made Easy:

    • Pose questions to AI models effortlessly and engage in dynamic conversations with askai and askai_follow_up functions.
  7. :page_facing_up: File Handling Simplified:

    • Manage files seamlessly, including uploads, retrievals, and deletions with dedicated functions.
  8. :chart_with_upwards_trend: Data Aggregation and Summarization:

    • Aggregate and summarize data effortlessly, gaining insights at your fingertips.
  9. :star2: Advanced Schema Management:

    • Dynamically create, delete, and modify tables and columns with ease.
  10. :zap: Efficient Bulk Operations:

    • Leverage bulk processing and transactions for lightning-fast database operations.
  11. :framed_picture: Image Transformation Capabilities:

    • Transform images on-the-fly with the image_transform function.
  12. :globe_with_meridians: Pagination for Large Datasets:

    • Navigate through large datasets seamlessly with next_page and prev_page functions.
  13. :rocket: Developer-Friendly:

    • Designed for developers by developers, ensuring a smooth and intuitive experience.

Features

:mag: Data Manipulation Made Easy

methods
  • query: Execute queries on specific tables with precision.
  • get: Retrieve records using record IDs.
  • insert: Seamlessly insert records into tables.
  • upsert: Replace records with ease.
  • update: Effortlessly update records in your tables.
  • delete: Remove records effortlessly.

:mag_right: Advanced Search Capabilities

methods
  • search: Discover specific queries in a branch.
  • search_on_table: Uncover data in a table using a search query.
  • vector_search: Harness the power of vector searches.

:bar_chart: Data Aggregation and Summarization

methods
  • aggregate: Aggregate data based on queries.
  • summarize: Summarize data in tables with precision.

:arrows_counterclockwise: Transaction Management

methods
  • transaction: Perform transactions effortlessly.
  • sql_query: Execute SQL queries seamlessly.

:brain: AI Integration

methods
  • askai: Pose questions and receive AI-driven responses.
  • askai_follow_up: Engage in dynamic conversations with AI models.

:file_folder: File Handling Made Simple

methods
  • upload_file: Upload files to specific tables and records.
  • get_file: Retrieve files with ease.
  • delete_file: Effortlessly remove files from your database.

:framed_picture: Image Transformation

methods
  • image_transform: Transform images effortlessly.

:page_facing_up: Pagination and Schema Management

methods
  • next_page: Retrieve the next page of results.
  • prev_page: Access the previous page of results.
  • get_schema: Explore table schemas dynamically.

:hammer_and_wrench: Database Administration

methods
  • create_table: Create new tables effortlessly.
  • delete_table: Remove tables with precision.
  • create_column: Add new columns seamlessly.
  • delete_column: Effortlessly remove columns.
  • get_columns: Retrieve table columns dynamically.

:rocket: Bulk Operations and API Requests

methods
  • bulk_processor: Facilitate bulk processing effortlessly.
  • bulk_transaction: Manage bulk transactions seamlessly.
  • api_request: Create custom API requests with ease.

Usage

1. Set up your Xata and Streamlit Environment

:globe_with_meridians: Create a Xata Account and Database at Xata.io:

  • Sign up for Xata and establish your database for a seamless integration experience.

:key: Generate Your API Key:

  • Access your Xata account settings to generate a unique API key for secure connections.

:globe_with_meridians: Get Your Xata Database URL Endpoint:

  • Retrieve the URL endpoint of your Xata database for streamlined connectivity.

:bulb: Install st_xata_connection Package:

  • Run pip install st-xatadb-connection.

2. Configure Your Xata Credentials

:lock: Securely Store Your Credentials:

  • Safeguard your Xata API key and database URL using Streamlit’s secrets manager or environment variables.

:wrench: Example Configuration:

  • Set your Xata API key: XATA_API_KEY = "YOUR_XATA_API_KEY"
  • Define your Xata database URL: XATA_DB_URL = "YOUR_XATA_DATABASE_URL"

3. Connect to Your Xata Database

Here’s a sneak peek into how incredibly simple it is to use st-xatadb_connection:

import streamlit as st
from st_xatadb_connection import XataConnection

# Connect to your Xata.io database
xata = st.connection('xata', type=XataConnection)

# Query your 'Table_name' 
response = xata.query("Table_name")

# Display the query results in your Streamlit app
st.write(response)

The response looks like this:

{
    "records": [
        {
          "id": "rec_c8hng2h26un90p8sr7k0",
          "name": "Matrix",
          "owner": {
            "id": "myid"
          },
          "xata": {
            "version": 0,
            "createdAt": "2023-05-15T08:21:31.96526+01:00",
            "updatedAt": "2023-05-15T21:58:54.072595+01:00"
          }
        }
    ],
    "meta": {
        "page": {
            "cursor": "jMq7DcIwEIDhnjH-2sWRAsItAT2KkOU8bAgB3Zkqyu6IDei_",
            "more": false
        }
    }
}

That’s it! With just a few lines of code, you’ve created a fully functional web application that displays data from your Xatadatabase.

Acknowledgements

I would like to express my gratitude to:

  • Xata Team: For providing an exceptional database platform.

:page_facing_up: Package documentation: Docs

:globe_with_meridians: Learn More: Xata Docs

:bulb: Why wait? Xata offers all these features for FREE!

:star: Star the repo on GitHub:
GitHub stars

:rocket: Unleash your creativity, streamline your development, and build applications that make an impact.

Check Out the Demo Apps Below to See st_xatadb_connection in Action!


:rainbow: Try Xata Now and Build Your Own Apps for FREE!

1 Like