Python Forum
python transfer Sql table to csv using BCP
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python transfer Sql table to csv using BCP
#1
Hi Team,

I am using below code for transfering data to CSV File,
code is working , But headers are missing .

can you please suggest how to include header in it.

from pathlib import Path
import subprocess

source_table = "xxx_xxxx_xxx_POC.dbo.Table1"
destination = str(Path("E:\test\table1.csv"))
subprocess.run(["bcp", source_table, "out", destination,  "-ABCD12345678\\ABCD5678,10010","-c", '-t"|"', "-T" ])
Reply


Messages In This Thread
python transfer Sql table to csv using BCP - by mg24 - Sep-29-2022, 12:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  file transfer via python SFTP SCP mg24 3 3,060 Sep-15-2022, 04:20 AM
Last Post: mg24
  DNP3 file transfer with python Aussie 0 1,479 Sep-01-2020, 10:45 PM
Last Post: Aussie
  Python script that transfer it self iboman5 6 4,573 Nov-13-2017, 05:27 PM
Last Post: AceScottie
  Python script that transfer it self iboman5 2 3,071 Nov-10-2017, 06:56 PM
Last Post: iboman5

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020