Skip to content

Oam11/QueryStream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Function/Module Documentation

db_query_generator.py

Function: get_database_schema

Simplifies database schema extraction and provides an efficient, reliable, and user-friendly solution for managing database data structures.

Function Description

This function extracts the database schema from a SQLite database, including table names and columns. It simplifies complex database operations by providing a clear and structured approach to schema analysis.

Example:

"[db_query_generator] is designed to extract database schema from a SQLite database and provide an efficient solution for managing database data structures."

Main Features

  • Simplifies database schema extraction using SQL queries
  • Provides a clear and structured approach to schema analysis
  • Supports various database management systems, including SQLite
  • Handling exceptions during database operations

Core Functionalities

  • Database schema extraction using SQL queries (SQLite, SQLite3, and PostgreSQL)
  • Support for various database systems, including SQLite, PostgreSQL, and MySQL
  • Error handling for exceptions during database operations

Advanced or Unique Features

  • Supports querying table structures using regular expressions
  • Generates SQL queries for data analysis and cleaning
  • Provides insights into the database schema using Python's pandas library

Benefits or Enhancements over Alternatives

  • Faster and more efficient than manual database schema analysis
  • No need to navigate complex database schema graphs
  • Automated database schema extraction and management
  • Error-free database operations with robust exception handling

Parameters

| Parameter Name | Data Type | Purpose | Example | | --- | | | | | db_file_path | str | Path to the SQLite database file. | st.file_uploader("Upload Your Database") | | schema | dict | Database schema to be extracted. | get_database_schema(st/file_uploader("Upload Your Database")) |

Attributes

st.session_state['db_file_path']

Path to the SQLite database file.

st.session_state['schema']

Database schema to be extracted.

llm (optional)

Instance of the ChatGroq model for generating SQL queries.

Class Documentation

db_query_generator.py

initialize_groq_mixtral

Initializes the Groq Mixtral model with a specified API key.

Class Attributes

st.session_state['llm']

Instance of the ChatGroq model for generating SQL queries.

llm_models.py

Module containing the ChatGroq model for generating SQL queries.

Methods

get_database_schema(db_file_path)

Extracts the database schema from a SQLite database file.

def get_database_schema(db_file_path):
    try:
        cursor = db_file_path.cursor()
        tables_query = "SELECT name FROM sqlite_master WHERE type='table';"
        cursor.execute(tables_query)
        tables = cursor.fetchall()
        
        schema = {}
        for table in tables:
            table_name = table[0]
            schema[table_name] = []
            cursor.execute(f"PRAGMA table_info({table_name});")
            columns = cursor.fetchall()
            for column in columns:
                schema[table_name].append(column[1])
        return schema
    except Exception as e:
        st.error(f"Error fetching database schema: {str(e)}")

Inherited Members

  • os
  • sqlite3
  • pandas

Side Effects

  • No side effects reported.

Inline Comments

get_database_schema function

Shows how to access the st.session_state['db_file_path'] variable in the function.

initialize_groq_mixtral function

Describes how to create an instance of the ChatGroq model for generating SQL queries.

Function Comments

get_database_schema function

Summarizes the purpose and assumptions of the function.

initialize_groq_mixtral function

Summarizes the purpose and assumptions of the function.

Class Documentation

initialize_groq_mixtral

Initializes the Groq Mixtral model with a specified API key.

def initialize_groq_mixtral(api_key):
    try:
        # Initialize Groq Mixtral model with the specified API key.
        # Provide your API key here.
        pass
    except Exception as e:
        # Display any errors that occur during initialization.
        st.error(f"An error occurred while initializing Groq Mixtral model: {str(e)}")

About

To access QueryStream, visit the link below

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published