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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:53:45+00:00 2026-05-31T12:53:45+00:00

I have created a database with MySQLdb. In database I have a table with

  • 0

I have created a database with MySQLdb.
In database I have a table with name student with columns:

id(is int),
id_user(is int),
f_name(is str),
l_name(is str)

I update a row with a function Update.
My code is below:

    def UpdateUser(self,e):         
        self.checkid_user=int(self.updateid[0]) #ok there
        self.c2name=self.name.GetValue() #this is from a textctrl in wxpython
        self.c2lastname=self.lastname.GetValue()#this is from a textctrl in wxpython

        ne=self.c2name.encode("utf-8")#greek word
        fe=self.c2lastname.encode("utf-8")#greek word

        f="'"+str(ne)+"'"
        l="'"+str(fe)+"'"

        print f #ok
        print l #ok
        db=mdb.connect(host="localhost",use_unicode="True",charset="utf8",user="root",passwd="root",db="test")
        cursor = db.cursor()

        sql="""SELECT id_user FROM student"""

        try:
            # Execute the SQL command
            cursor.execute(sql)
            # Commit your changes in the database
            db.commit()
        except:
            # Rollback in case there is any error
            db.rollback()

        rows = cursor.fetchall()

        for row in rows:
            r=int(row[0])
            if r==self.checkid_user:                    #ok there
                sql2 = """UPDATE student
                SET f_name=%s,l_name=%s
                WHERE id_user=%s"""

               # Execute the SQL command
                cursor.execute(sql2(f,l,r))
        # Commit your changes in the database
                db.commit()

                db.rollback()
# disconnect from server
db.close()

When I run the function i take the follow error:

typeerror 'str' object is not callable

I use f and l to be callable but nothing.
I need some help here to solve that problem. 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-31T12:53:47+00:00Added an answer on May 31, 2026 at 12:53 pm

    There may be other problems, but let’s start with this:

    cursor.execute(sql2(f,l,r))
    

    …is wrong.

    You need a comma between the arguments:

    cursor.execute( sql2, (f,l,r) )
    

    Your code looks like a function call: this_is_how_we_call_a_func() <- note the parens!
    But sql2 only contains a string, which is — as the evidence will show — not callable…

    >>> dir(sql2)
    ['__add__', '__class__', '__contains__', '__delattr__', ... other stuff
    
    >>> def my_func(): pass
    ...
    >>> dir(my_func)
    ['__call__', '__class__', '__closure__', '__code__', ... other stuff
     ^^^^^^^^^^
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a database with MySQLdb. In database I have a table with
I have a mysql database table called character with columns like name, strength, intelligence,
I have created a table on an Oracle 10g database with this structure :
I am playing with wpf and when i have created database it is created
I have created a MySQL database using MySQL Workbench. It has about 20 tables.
I have a database that I have created using SQL Server Developer 2008. I
I have created one user named tuser with create database rights in SQL server
I have created a shell script to backup my webfiles + database dump, put
I have created a simple windows service that periodically checks a remote database via
I have created a Windows Service in VB.net for building xML from a database.

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.