Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6662481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:23:38+00:00 2026-05-26T02:23:38+00:00

I am using python scripts to load data to a database bulk loader. The

  • 0

I am using python scripts to load data to a database bulk loader.

The input to the loader is stdin. I have been unable to get the correct syntax to call the unix based bulk loader passing the contents of a python list to be loaded.

I have been reading about Popen and PIPE but they have not been behaving as i expect.

The python list contains database records to be bulkloaded. In linux it would look similar to this:

echo "this is the string being written to the DB" | sql -c "COPY table FROM stdin"

What would be the correct way replace the echo statement with a python list to be used with this command ?

I do not have sample code for this process as i have been experimenting with the features of Popen and PIPE with some very simple syntax and not obtaining the desired result.

Any help would be very much appreciated.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:23:39+00:00Added an answer on May 26, 2026 at 2:23 am

    If your data is short and simple, you could preformat the entire list and do it simple with subprocess like this:

    import subprocess
    data = ["list", "of", "stuff"]
    proc = subprocess.Popen(["sql", "-c", "COPY table FROM stdin"], stdin=subprocess.PIPE)
    proc.communicate("\n".join(data))
    

    If the data is too big to preformat like this, then you can attempt to use the stdin pipe directly, though subprocess module is flaky when using the pipes if you need to read from stdout/stderr too.

    for line in data:
        print >>proc.stdin, line
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using NotePAD++ for editing Python scripts. I recently downloaded the PyDEV
I am unable to install pymongo using easy_install on python 3.2. c:\Python32\Scripts>easy_install pymongo ...
I have been trying to get slimv (http://www.vim.org/scripts/script.php?script_id=2531) working for a while now, but
I have been writing command-line Python scripts for a while, but recently I felt
I'm trying to run Python scripts using Xcode's User Scripts menu. The issue I'm
I have a batch file containing a python script using the Output template> %(NAME)s
I have a Python script I recently wrote that I call using the command
Suppose I have a python script called my_parallel_script.py that involves using multiprocessing to parallelize
I have a Python script which uses the MySQLdb interface to load various CSV
While I have been playing with Python for a few months now (just a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.