Using Mysqldb rather than sqlalchemy


import MySQLdb
import sys
import time
times=time.time()
try:
    conn = MySQLdb.connect (host = "spider.db", user = "root", passwd = "", db = "spider")
except MySQLdb.Error, e:
    print "Error %d: %s" % (e.args[0], e.args[1])
    sys.exit (1)
print (time.time()-times), ": Connect to MySql"
rdomains=[]
db = conn.cursor ()
q = "SELECT DISTINCT url_queue.rdomain FROM url_queue WHERE url_queue.is_disabled =0"
print (time.time()-times), ": Initializing MySQL Query"
db.execute(q)
print (time.time()-times), ": The query has executed successfully. \n Now, fetching data to rdomain" 
rdomains=db.fetchall()
print (time.time()-times), ": Data has been fetched and saved to rdomains! :)"

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: