Hi there! I new learner in Python. And just couldn't get threading. I wrote this script.

import sys
import MySQLdb

if len(sys.argv)!=3:
    """the program name, mac and ip makes three"""
    """stop program and send error"""
    sys.exit("Must provide mac and ip!")

mac = sys.argv[1]
ip = sys.argv[2]

print 'Connected to server'

#saving ip to database!
# Open database connection
db = MySQLdb.connect("localhost","user","pass","dbname" )

# prepare a cursor object using cursor() method
cursor = db.cursor()

# Prepare SQL query to UPDATE required records
sql = "UPDATE mac_list SET ip ='"+ip+"' WHERE mac='"+mac+"'"
   # Execute the SQL command
   # Commit your changes in the database
   print (mac+' and '+ip+' entered to database')
   # Rollback in case there is any error
   print ('something went wrong')
# disconnect from server

And I want to thread it. So that when called it won't have to wait for the previous call. How can I do that?

Criticisms on above code will be greatly appreciated!
Thanks in advance!

P.S. An example call would be

python getmacip.py [some-MAC] [some-IP]

Yeah... I can see that... I would have rather gotten a quick answer than to read documentation... But thanks... I think... But if anyone else could help that will still be great!

I wrote a tutorial about threading. A simple one :).
Check out the tutorial section.

I would have rather gotten a quick answer than to read documentation...

The classic Lazy. :icon_rolleyes:
Though I will admit, reading documentation isn't a very good
tutorial source and it is quite boring.