Skip to content
Advertisement

Getting SQL Column to print in Python

I have a code that prints out a specific column from an SQL query table. It prints out fine however I would like it to be put into a file and I cannot think of how to do that.

Here is what I have:

JavaScript

I was thinking of newfile.write( df[['PartNumber']].to_string() ) however that did not work.

Thank you for your help

Advertisement

Answer

Depending on what type of file, pandas supports many formats For a simple csv file you can do:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement