When you create a connection to Vantage, you have the option to either specify a default database, or rely on the default database of the connecting user. However, it is also possible to interact with the tables in a database other than the default using the following approaches.
Using the in_schema() function
The in_schema() function takes a schema name and a table name and creates a database object name in the format "schema"."table_name".
The following example creates a DataFrame from the existing Vantage view "dbcinfo" in the non-default database "dbc" using the in_schema() function.
>>> from teradataml.dataframe.dataframe import in_schema
>>> df = DataFrame(in_schema("dbc", "dbcinfo")) >>> df InfoKey InfoData 0 RELEASE 16.20.27.01 1 LANGUAGE SUPPORT MODE Standard 2 VERSION 16.20.27.01
Using fully qualified table name
Teradata recommends using in_schema() to create a dataframe, as shown in the previous section.
Teradata does not recommend using fully qualified table name while creating a dataframe.
You can use fully qualified table name that can be passed to the from_table() function or fully qualified table in SQL that can be passed to the from_query() function.
- Example: Using from_table() and fully qualified table name
>>> from teradataml.dataframe.dataframe import DataFrame
>>> df = DataFrame.from_table('"dbc"."dbcinfo"') >>> df InfoKey InfoData 0 LANGUAGE SUPPORT MODE Standard 1 RELEASE 16.20.27.01 2 VERSION 16.20.27.01 >>>
- Example: Using from_query() and fully qualified table name in SQL
>>> from teradataml.dataframe.dataframe import in_schema
>>> df = DataFrame.from_query("SELECT * FROM dbc.dbcinfo") >>> df InfoKey InfoData 0 RELEASE 16.20.27.01 1 LANGUAGE SUPPORT MODE Standard 2 VERSION 16.20.27.01 >>>