Skip to content

Instantly share code, notes, and snippets.

@rogaha
Created April 30, 2014 21:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogaha/8788a5f852cf04265bbe to your computer and use it in GitHub Desktop.
Save rogaha/8788a5f852cf04265bbe to your computer and use it in GitHub Desktop.
connection = mdb.connect(db_host, db_user, db_password, db_name, port=db_port)
cursor = connection.cursor(mdb.cursors.SSDictCursor)
cursor.execute("select user_agent from {0} where {1} LIKE "
"'%{2}%'".format(table_name, filter_field, filter_value))
row = cursor.fetchone()
# Fetch each row at a time instead of fetching everything at once
# It improves the memory usage on the client side
while row is not None:
results.append(row)
row = cursor.fetchone()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment