ITTips
PythonTips
Install MySQLdb connector on Mac OSX
To install the python/
MySQL connector on Mac OS X follow the following tutorials:
MySQL connection
You have to create a cursor to connect to the database.
The cursor is created with
MySQLdb.connect.
Then in the cursor class, you have a couple of methods:
- execute(): to execute a mysql query
- rowcount(): will return the number of lines of your sql query
- fetchall(): get all the results from your sql query
- fetchone(): method used to move forward through the resultset
2 ways to create sql queries and execute them:
sqlInsert = "insert into servers set servername='%s',location='%s',purpose='%s',live='%s',coderelease='%s'" % (servername,location,purpose,live,coderelease)
cursor.execute(sqlInsert)
cursor.execute("insert into servers set servername='%s',location='%s',purpose='%s',live='%s',coderelease='%s'" , (servername,location,purpose,live,coderelease))
The 1st one being the neater!
methods definition
When defining your class methods, you must explicitly list self as the first argument for each method, including
init
built in functions
http://docs.python.org/lib/built-in-funcs.html∞
Python Editor
SPE. To install it on mac, you need the python framework and wxpython:
http://www.wxpython.org∞
If you want to change the way shortcut are bound on your keyboard please check this post:
https://lists.berlios.de/pipermail/python-spe-dev/2005-December/000075.html∞
Basically, shortcuts are defined in
Contents/Resources/_spe/shorcuts/OS.py
Sending emails in HTML with attached documents
http://code.activestate.com/recipes/473810/∞
There are no comments on this page. [Add comment]