Created
January 8, 2014 07:03
-
-
Save stefanmonkey/8312902 to your computer and use it in GitHub Desktop.
_mysql_module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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