Q:

What is better in python, a Dictionary or Mysql?

What would be faster ?
Query mysql to see if the piece of information i need is there, OR
load a python dictionary with all the information then just check if the id is there
If python is faster, then whats the best what to check if the id exists?
Im using python 2.4.3
Im searching for data which is tagged to a square on a board, im searching for x&y.
Theres only one entry per square, the information wont change and it needs be recalled several times a second.
Thankyou !
Finished
I worked out it was python. I ran the code bellow, and mysql did it in 0.0003 of a second, but python did it in 0.000006 of a second and mysql had far far less to search and the test was run how the code would be running in real life. Which one had less overhead in terns of CPU and RAM i will never know but if speed is anything to go by python did much better.
And thankyou for your answers !
def speedtest():
 global search
 global data
 qb = time.time()
 search.execute("SELECT * FROM `nogo` where `1`='11' AND `2`='13&3'")
 qa = search.fetchall()
 print qa[0]
 qc =  time.time()
 print "mysql"
 print qb
 print qc
 print qc - qb

 data = {}
 for qa in range(15):
  data[qa] = {}
  for qb in range(300):
   data[qa][str(qb)] = 'nogo'
 qw = 5
 qe = '50'
 qb = time.time()
 print data[qw][qe]
 qc =  time.time()
 print "dictionary"
 print qb
 print qc
 print qc - qb

A:

Generally speaking, if you want information from a database, ask the database for what you need. MySQL (and other database engines) are designed to retrieve data as efficiently as possible. 
Trying to write your own procedures for retrieving data is trying to outsmart the talented people who have already imbued MySQL with so much data processing power.
This isn't to say it's never appropriate to load data into Python, but you should be sure that a database query isn't the right way to go first.

