vanna.base.base
Helper class that provides a standard way to create an ABC using inheritance.
Example:
vn.generate_questions()
Generate a list of questions that you can ask Vanna.AI.
Connect to a SQLite database. This is just a helper function to set [vn.run_sql
][vanna.run_sql]
Arguments:
- url (str): The URL of the database to connect to.
Returns:
None
Connect to postgres using the psycopg2 connector. This is just a helper function to set [vn.run_sql
][vanna.run_sql]
Example:
vn.connect_to_postgres(
host="myhost",
dbname="mydatabase",
user="myuser",
password="mypassword",
port=5432
)
Arguments:
- host (str): The postgres host.
- dbname (str): The postgres database name.
- user (str): The postgres user.
- password (str): The postgres password.
- port (int): The postgres Port.
Connect to gcs using the bigquery connector. This is just a helper function to set [vn.run_sql
][vanna.run_sql]
Example:
vn.connect_to_bigquery(
project_id="myprojectid",
cred_file_path="path/to/credentials.json",
)
Arguments:
- project_id (str): The gcs project id.
- cred_file_path (str): The gcs credential file path
Example:
vn.train()
Train Vanna.AI on a question and its corresponding SQL query.
If you call it with no arguments, it will check if you connected to a database and it will attempt to train on the metadata of that database.
If you call it with the sql argument, it's equivalent to [add_sql()
][vanna.add_sql].
If you call it with the ddl argument, it's equivalent to [add_ddl()
][vanna.add_ddl].
If you call it with the documentation argument, it's equivalent to [add_documentation()
][vanna.add_documentation].
Additionally, you can pass a [TrainingPlan
][vanna.TrainingPlan] object. Get a training plan with [vn.get_training_plan_experimental()
][vanna.get_training_plan_experimental].
Arguments:
- question (str): The question to train on.
- sql (str): The SQL query to train on.
- ddl (str): The DDL statement.
- documentation (str): The documentation to train on.
- plan (TrainingPlan): The training plan to train on.
Example:
fig = vn.get_plotly_figure(
plotly_code="fig = px.bar(df, x='name', y='salary')",
df=df
)
fig.show()
Get a Plotly figure from a dataframe and Plotly code.
Arguments:
- df (pd.DataFrame): The dataframe to use.
- plotly_code (str): The Plotly code to use.
Returns:
plotly.graph_objs.Figure: The Plotly figure.
Helper class that provides a standard way to create an ABC using inheritance.
Inherited Members
- VannaBase
- config
- run_sql_is_set
- generate_sql
- generate_followup_questions
- generate_questions
- generate_embedding
- add_question_sql
- add_ddl
- add_documentation
- get_training_data
- remove_training_data
- get_sql_prompt
- get_followup_questions_prompt
- submit_prompt
- generate_question
- generate_plotly_code
- connect_to_snowflake
- connect_to_sqlite
- connect_to_postgres
- connect_to_bigquery
- run_sql
- ask
- train
- get_training_plan_generic
- get_training_plan_snowflake
- get_plotly_figure