OUTPUT TO csv file - SQL Anywhere using pyodbc gives error

604 Views Asked by At

I am using the following query with pyodbc:

def generiere():
    query = """SELECT ArtikelNr, Artikel_Bezeichnung, Artikel_Menge, System_created, Summen_netto, Summen_brutto, Summen_ust_gesamt FROM FK_AuftragPos;OUTPUT TO 'C:/Users/User/Documents/Software/Statistik/test.csv' FORMAT TEXT QUOTE '"' DELIMITED BY ';' WITH COLUMN NAMES"""
    cursor.execute(query)

When I use this query in Interactive SQL it all works. But when I try to use it in my Python program I get the following error:

Syntax error at 'OUTPUT' ... (-131) (SQLExecDirectW)

I just do not know what I am doing wrong.

Edit: Provided more code and information.

1

There are 1 best solutions below

4
On

the last part of your query ;OUTPUT TO 'C:/Users/User/Documents/Software/Statistik/test.csv' FORMAT TEXT QUOTE '"' DELIMITED BY ';' WITH COLUMN NAMES is not valid syntax for the query

it might be valid in an interactive console to the db, but that are then commands from the interactive console