Introduce Database class abstracting MySQL access
Closed this issue · 0 comments
macbre commented
- report list of tables
- report tables schema - columns, indices and stats
- allow to run
EXPLAIN
query - take DSN-style URI as an argument (completed in #9):
from urlparse import urlparse
r = urlparse('mysql://alex:pwd@localhost/test')
print(r.username)
# 'alex'
print(r.password)
# 'pwd'
import MySQLdb
db=MySQLdb.connect(passwd="moonpie",db="thangs")
# ---
c=db.cursor()
max_price=5
c.execute("""SELECT spam, eggs, sausage FROM breakfast
WHERE price < %s""", (max_price,))
# ---
>>> c.fetchone()
(3L, 2L, 0L)