A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/072395.html below:

MySQSLdb: just guessing

MySQSLdb: just guessingCarsten Gaebler cg at schlund.de
Wed Apr 25 04:02:55 EDT 2001
Albert Wagner wrote:
> 
> I can find no docs for MySQLdb, so I am just guessing how to get going.  I
> got this far by trial and error:
> 
> >>> import _mysql
> >>> from _mysql import *
> >>> connection = connect('myhostname', 'mypassword')
> >>>
>

MySQLdb is very poorly documented. But if you browse through the dbtrainer
files in the doc/ directory you'll come across something like this:


import MySQLdb

# Establish a connection:
db=MySQLdb.connect(host='myhost',db='mydatabase',user='itsme',passwd='wonttellyou')

# Fetch a table list
c = db.cursor()
c.execute('show tables')
print c.fetchall()

# fetchall() is bad for huge results.
# use fetchmany() or fetchone()
c.execute('select * from a_huge_table')
while 1:
	rows = c.fetchmany(10)
	if not rows: break
	for row in rows:
	print row


db.close()


cg.

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4