• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Anyone Know Python?

BChico

Platinum Member
Trying to write a client with Boa to connect to a MySQLdb. I dont know python very well. When i am getting data back from MySQL how should i send it to the txtbox for results...this is what i have:

try:
con = MySQLdb.Connect( host = self.server_txt_box.GetValue(),
user = self.user_txt_box.GetValue(),
passwd = self.password_txt_box.GetValue(),
db = self.database_txt_box.GetValue())

cursor = con.cursor()
query = self.query_txt_box.GetValue()
cursor.execute( query )

res = cursor.fetchall()

for rec in res:
for field in rec:
self.results_txt_box.AppendText(str(field))

con.close()

except MySQLdb.Error, e:
self.results_txt_box.AppendText("Error %d: %s" % (e.args[0], e.args[1]))


That prints everything on one line. I need to put a new line after each record is there a way to insert a carrige return or something?

Thanks
 
Also for some reason in my text box i cannot even manually enter a new line, just by pressing return, is this normal?
 
When you make a post, there is an "attach code" button, that lets you paste in code and it'll preserve whitespace and display in a monospace font. Your code is hard to read when you just paste it into your post as normal text.

If \r\n doesn't work, then I dunno. Is this textbox even capable of displaying multi-line text?

Are you even on windows? It'd help if you gave more details.
 
ya know sometimes i think i am retarded...forgot to add wxTE_MULTILINE to the style of the text box...god this is gonna be a long night...thanks bingbong
 
Im working on windows, this is a project for a databasing class. Pretty much its a client that takes in a command, you hit execute, its connects to the database, and you put the output from mysql into a results window. Im really not sure how to do exception handling thats what i have to tackle next...my prof didnt tell us anything...

EDIT: Working with Boa by the way
 
Is there a better way to accept the incoming data than this:

for rec in res:
for field in rec:
self.results_txt_box.AppendText(str(field))
self.results_txt_box.AppendText("\r\n")

I was using this for a command line client:

for rec in result:
for field in rec:
print field, "\t",
print
 
Back
Top