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 8962373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:06:43+00:00 2026-06-15T16:06:43+00:00

I am using python to copy one table (dictionary) to another (origin_dictionary) in SQLite,

  • 0

I am using python to copy one table (dictionary) to another (origin_dictionary) in SQLite, and here is my code to this part:

    def copyDictionaryToOrigin(self):
    dropTableQueryStr = "DROP TABLE IF EXISTS origin_dictionary"
    createTableQueryStr = "CREATE TABLE origin_dictionary (id INTEGER PRIMARY KEY AUTOINCREMENT, word TEXT, type TEXT)"
    syncTableQueryStr = "INSERT INTO origin_dictionary (word, type) SELECT word, type FROM dictionary"

    self.cur.execute(dropTableQueryStr)
    self.cur.fetchone()

    self.cur.execute(createTableQueryStr)
    result = self.cur.fetchone()

    self.cur.execute(syncTableQueryStr)
    result = self.cur.fetchone()

With running this code, I can see a origin_dictionary table is created, but there is no data in the table. I could not find out the reason why the data didn’t copy over to the new table. can someone please help me with this?

  • 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-15T16:06:44+00:00Added an answer on June 15, 2026 at 4:06 pm

    If you need to simply copy one table to another, why don’t you use CREATE TABLE ... AS SELECT? Also, you need to commit() your statements.

    Simply use code below, and it should work:

    import sqlite3
    conn = sqlite3.connect(example.db")
    cur = conn.cursor()
    cur.execute("DROP TABLE IF EXISTS origin_dictionary")
    cur.execute("CREATE TABLE origin_dictionary AS SELECT * FROM dictionary")
    conn.commit()
    conn.close()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to copy all the files present in one directory to another directory using
Using Python (2.7)and sqlite (3) I am trying to copy results of a query
I am using python and postgresql. I have a table with 6 column. One
This question has been asked here in one form or another but not quite
Using Python, how does one parse/access files with Linux-specific features, like ~/.mozilla/firefox/*.default ? I've
I am using Python/ctypes to wrap a C library. One of the structures I
A proper header format in python is described here . Using either VIM or
I want to copy a message from one IMAP server to another IMAP server.
I am designing a Copy/Paste Application for Windows os using Python.Now I want to
newcomer and first ever question here. I am using the multiprocessing module of Python

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.