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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:40:23+00:00 2026-06-09T14:40:23+00:00

I have been learning to use sqlite3 with python. Right now, I have a

  • 0

I have been learning to use sqlite3 with python. Right now, I have a function that takes a word and looks up the definition of that word on the internet. I then try to store the word in one table and the definitions into another table linked together by a foreign-key.

Like this:

#! /usr/bin/env python
import mechanize
from BeautifulSoup import BeautifulSoup
import sys
import sqlite3

def dictionary(word):
    br = mechanize.Browser()
    response = br.open('http://www.dictionary.reference.com')
    br.select_form(nr=0)
    br.form['q'] = word 
    br.submit()
    definition = BeautifulSoup(br.response().read())
    trans = definition.findAll('td',{'class':'td3n2'})
    fin = [i.text for i in trans]
    query = {}
    word_count = 1
    def_count = 1
    for i in fin: 
        query[fin.index(i)] = i
    con = sqlite3.connect('vocab.db')
    with con:
        spot = con.cursor()
        spot.execute("SELECT * FROM Words")
        rows = spot.fetchall()
        for row in rows:
            word_count += 1
        spot.execute("INSERT INTO Words VALUES(?,?)", word_count,word)
        spot.execute("SELECT * FROM Definitions")
        rows = spot.fetchall()
        for row in rows:
            def_count += 1
        for q in query:
            spot.execute("INSERT INTO Definitions VALUES(?,?,?)", def_count,q,word_count)
    return query

print dictionary(sys.argv[1]) 

When I run it:

./database_trial.py 'pass'

This is the error message:

Traceback (most recent call last):
  File "./database_trial.py", line 37, in <module>
    print dictionary(sys.argv[1])  
  File "./database_trial.py", line 28, in dictionary
    spot.execute("INSERT INTO Words VALUES(?,?)", word_count,word)
TypeError: function takes at most 2 arguments (3 given)

Inside the function I only have two arguments being passed to the ‘Words’ table but, the message says there are three?

spot.execute("INSERT INTO Words VALUES(?,?)", word_count,word) 

I’m thought I might be messing something up with sys.argv. So I went through and change that line to:

spot.execute("INSERT INTO Words VALUES(?,?)", word_count, sys.argv[1])

I still got the same results with the error message?

  • 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-09T14:40:24+00:00Added an answer on June 9, 2026 at 2:40 pm
    spot.execute("INSERT INTO Words VALUES(?,?)", word_count,word) 
    

    There are three arguments being passed to the method spot.execute: the SQL string, the variable word_count, and the variable word. I suspect the values to enter into the database need to be enclosed in a tuple to form a single argument:

    spot.execute("INSERT INTO Words VALUES(?,?)", (word_count,word))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been learning python for some time now. While starting this learning python
I have been learning Python for a while, and now I'd like to learn
I have been learning to use Emacs for a little while now. So far
I have been learning how to use the Python multiprocessing module recently, and reading
I am learning to use mysql for rails apps, and I finally have been
I have been learning Scala for the past couple of months and now I
I have been learning a bit of Python 2 and Python 3 and it
I have been learning php for sometime now. Besides reading books and doing tutorials
I have been learning Python by following some pygame tutorials . Therein I found
I have been a python programmer 7+ years now, and been designing with PyQt

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.