Connecting to the database
Learn how to connect to the databases and tables in the databases.
Procedure
- For an ODBC connection, follow the steps that are described in Installing and configuring ODBC.
Now, you can connect to databases and tables.
-
To connect to a database, run:
from nzpyida import IdaDataBase, IdaDataFrame idadb = IdaDataBase(DATASOURCE NAME, USERNAME, PASSWORD) - To connect to a table in that database,
run:
idadf = IdaDataFrame(idadb, TABLE NAME)
-
- For a JDBC connection:
- Follow the instructions that are described in Installing and configuring JDBC.
-
After you download and install the
nzjdbc3.jarfile, you must include its location in the value of theCLASSPATHenvironment variable.export CLASSPATH=PATH TO nzjdbc3.jar:$CLASSPATH
Now, you can connect to databases and tables.
- To connect to a database, run:
from nzpyida import IdaDataBase, IdaDataFrame jdbc_dsn = jdbc:netezza://IP ADDRESS:PORT/DATABASE NAME" idadb = IdaDataBase(jdbc_dsn, uid="USRENAME", pwd="PASSWORD") - To connect to a table in that database,
run:
idadf = IdaDataFrame(idadb, TABLE NAME)
- For an nzpy connection, if you have nzpyida,
you do not have to install drivers on the client side as with the ODBC and JDBC connections.
nzpyida supports a native Python driver
nzpy-based connection for Netezza Performance Server.You can declare connection credentials in the following format.
Where:nzpy_dsn = { "database":DATABASE NAME, "port" :5480, "host": SERVER NAME, "securityLevel":0, "logLevel":0 }database- Specifies the name of the database.
host- Specifies the IP address of the
nzserver. port- Specifies the port at which the
nzserver is running at.
Now, you can connect to databases and tables.
- To connect to a database, run:
from nzpyida import IdaDataBase, IdaDataFrame idadb = IdaDataBase(nzpy_dsn, uid="USERNAME", pwd="PASSWORD") - To connect to a table in that database, run:
idadf = IdaDataFrame(idadb, TABLE NAME)