MySQL returned datatype and python outputs different type for different functions -


I have a lot of problems with MySQL returns and it has been inserted into a QT table with Python. To use data = cursor.fetchall ()

 : for i category (data): sqlTableWidget.setItem (index, i, QtGui.QTableWidgetItem (data [i]) index = index1   

Basically I would have kept str () around the return, and it used to work for everything, except its That when I am abroad Unicode problems on language and date time so now I did not insert str () and foreign language on the table. However, now there are some problems with some strings

1) I do not include that time When I type type (data [i]) , it returns datetime and when I call it the data [i] = data [i] .strftime ( "% Y-% m-% d% H:% M:% S") It tells me 'Tupal' does not support object item assignment

2) Then I Just passed for that time. Now I try to get the integer to display. If data [i] == 1: print data [i] print type (data [i]) data [i] = str (data [i]) / Pre>

This results in the following:

  gt; 1 >> (type 'long')> gt; & Gt; Type error: does not support 'Tulle' object   

In addition, if I try to print

  print list (data [i])   

It returns:

  typeError: The 'long' object is not recurring.   

In addition, / P>

  if there is no data [i]: data [i] = 'no data' sqlTableWidget.setItem (index, i, qtigui.quitebitalititum (data [i]))   

returns:

  QTableWidgetItem (QtableWidgetItem): Logic 1 Unexpected type 'NoneType'   

I must be missing something fundamental about my return what caused it?

You can not change the data from the fetchall method because it is a Tupal and not a list. The easiest to decide:

  data = [for the list (i) I cursor.fetchol ()]    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -