pythonsqlnetezzaaginity

CREATE/DROP call from Python to SQL (Aginity, Netezza) not working


I am trying to figure out how to upload/insert csv table files into Aginity Workbench (uses Netezza driver) using Python for both existing and non-existing tables.

  1. Is there a function that does a direct upload from a specified pathway into the SQL database? I have been unable to find functions specific to Aginity/Netezza.
  2. I tried a step-by-step procedure: uploading csv into Python, converting to dataframe, then uploading to SQL database (would like to figure out how to upload full csv files as a new table as well as inserting csv file data into existing tables).

My Python code is able to print queries displaying data, but I'm unable to drop or create tables. It does not display any error when I run the create or drop code, however when I go into Aginity, the tables I intended to create do not exist, and the tables I want to drop were not dropped.

import pyodbc

# pyodbc connection string
conn = pyodbc.connect("DRIVER={driver};SERVER=server; PORT=port;DATABASE=database; UID=username;PWD=password;")

# Define Cursor
cus = conn.cursor()

# SQL query
sql = 'drop table username.test'
cus.execute(sql)

I get an output with no errors like the following, but the drop didn't actually happen.

<pyodbc.Cursor at 0x1ac108181b0>

Any tips would be greatly appreciated!


Solution

  • @roganjosh points out I should add conn.commit()