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

  • Home
  • SEARCH
  • 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 9018533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:33:05+00:00 2026-06-16T04:33:05+00:00

I am facing problems in coping data from one db to another db here

  • 0

I am facing problems in coping data from one db to another db here is python code.

import psycopg2

db = psycopg2.connect("dbname='db' user='xx' password='xx' host='127.0.0.2'")
st = db.cursor();

db_l = psycopg2.connect("dbname='xx' user='xx' password='xx' host='127.0.0.1'")
st_l = db_l.cursor();


q = "create table tarf as select i_rate, i_tariff As id, prefix, price_1, price_n, interval_1, interval_n, '00:00' AS start_time, '23:59:59' AS end_time, activation_dat
e, '3049-1-1 00:00' as exp  from rates JOIN tariffs USING (i_tariff) JOIN billing_plans USING(i_tariff) JOIN accounts using (i_billing_plan)"

st_l.execute(q)

f = open('tariff.sql','w')
st_l.copy_to(f,'tarf',sep=',')

st.copy_from(f,'tariff',sep=',')

Here is an error faced:

Traceback (most recent call last):
  File "sync_tariff.py", line 23, in <module>
    st.copy_from(f,'tariff',sep=',')
psycopg2.extensions.QueryCanceledError: COPY from stdin failed: error in .read() call
CONTEXT:  COPY tariff, line 1
  • 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-06-16T04:33:06+00:00Added an answer on June 16, 2026 at 4:33 am

    Close the file and then open it for reading

    f = open('tariff.sql', 'w')
    st_l.copy_to(f, 'tarf', sep=',')
    
    f.close()
    
    f = open('tariff.sql', 'r')
    st.copy_from(f, 'tariff', sep=',')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am facing a problem with extracting data from a database. The problem is
Guyz facing problems with creating a push notification service (for android) using Google C2DM
I'm facing problems with the UTF-8 encoding on Heroku. I need to pass the
I'm currently working on a new Magento template, and I'm facing problems with jQuery.
I've instaled MySQL workbench in Windows 7 64bit. Unfortunately, I'm facing problems: In the
I'm facing some problems with my silverlight application. My application looks like an image
I am facing some problems for using placement new for contiguous memory.Please guide me,
I'm new to Android programming, so I'm facing some general problems about choosing the
I am facing a couple of problems while writing an auto-memoizer in Scheme. I
Iam facing problem in understanding and converting a matlab code into opencv. I want

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.