Skip to content

Instantly share code, notes, and snippets.

@stefanmonkey
Created January 8, 2014 07:03
Show Gist options
  • Save stefanmonkey/8312902 to your computer and use it in GitHub Desktop.
Save stefanmonkey/8312902 to your computer and use it in GitHub Desktop.
_mysql_module
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import _mysql
import sys
try:
con = _mysql.connect('localhost', 'testuser', '123456', 'testdb')
con.query('select version()')
result = con.use_result()
print 'MySQL version: %s' % \
result.fetch_row()[0]
except _mysql.Error, e:
print "Error %d: %s" % (e.args[0], e.args[1])
sys.exit(1)
finally:
if con:
con.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment