Hello!
I have defined a function to create a combo box to log into a database

def comboLogin():
		import MySQLdb
		db= MySQLdb.connect(host='localhost', user='root' , passwd='acrsci00', db='Ornithobase')
		self.cursor = db.cursor()
		sql = '''select Username from Users'''
		self.cursor.execute(sql)
		result = self.cursor.fetchall()
		result2 = []
		x = 0
		for record in result:
			for field in record:
				users = str(field)
				result2.append(users)
				x += 1
		return result2
		db.close()

It should close the db connection, but when I login in another place of the class it logs in as root instead of the selected username.

try:
	db= MySQLdb.connect(host='localhost', user=Username , passwd=pwd, db='Ornithobase')
	self.cursor = db.cursor()

How can I solve it?
Cheers!

Dani

Recommended Answers

All 2 Replies

I would like to help, but I'm not understanding now mate.

Cheers and Happy coding

Don't worry. I was wrong.

Dani

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.