Note that there are some explanatory texts on larger screens.

plurals
  1. POSlow PDF render with PyQt from MySQL query
    primarykey
    data
    text
    <p>Until yesterday, I was using SQLite for my application. Today I found a reason strong enough (multiple instances of application) to switch to MySQL using <code>pymysql</code>.</p> <p>At one point, my application queries the database for 300 rows:</p> <pre><code>cur.execute('select ime,brPredmeta,statusStr,sudskiBr ,sudija ,datumRasprave,statusPredmeta, zaduzen,datumZaduzenja from predmeti') sviaktivni = cur.fetchall() sviaktivni = list(sviaktivni) #make a list of tuples sviaktivni.sort(key=operator.itemgetter(0)) #sort the list </code></pre> <p>After that, I extract the variables and then use those variables to make a HTML document, which is then sent to printer (PDF or regular printer). Code for generating HTML is pretty simple; table with few rows for "header" (omitted here for clarity), then another table for "body" with code like this:</p> <pre><code>#extract the variables for tuple in sviaktivni: ime,brPredmeta,statusStr,sudskiBr ,sudija ,datumRasprave,statusPredmeta, zaduzen,datumZaduzenja = tuple #done extracting body = ('&lt;html&gt;&lt;head&gt;&lt;title&gt;&lt;/title&gt;' '&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/&gt;' '&lt;style&gt;&lt;/style&gt;' '&lt;/head&gt;' '&lt;body&gt;' '&lt;table align ="center" border="0" width="100%" style="table-layout:fixed"&gt;' '&lt;tr height="10%"&gt;' '&lt;td align="left" width="20"&gt;'+str(brojac)+'.&lt;/td&gt;' '&lt;td align="left" width="180"&gt;'+ime+'&lt;/td&gt;' '&lt;td align="left" width="100"&gt;'+str(brPredmeta)+'&lt;/td&gt;' '&lt;td align="left" width="80"&gt;'+statusStr+'&lt;/td&gt;' '&lt;td align="left" width="80"&gt;'+str(sudskiBr)+'&lt;/td&gt;' '&lt;td align="left" width="140"&gt;'+sudija+'&lt;/td&gt;' '&lt;td align="left" width="150"&gt;'+zaduzen+'&lt;/td&gt;' '&lt;td align="left"&gt;'+datumZaduzenja+'&lt;/td&gt;' '&lt;td align="right"&gt; '+statusPredmeta+' &lt;/td&gt;' '&lt;/tr&gt;' '&lt;/table&gt;' '&lt;/body&gt;' '&lt;/html&gt;') self.ui.printHTML.append(body) </code></pre> <p>My problem is that the query is executed instantly, but after that CPU is stuck at 100%, and the whole program just freezes. Print preview dialog is sometimes shown with data, sometimes it's just an empty window. Either way, whole app is frozen.</p> <p>There were no problems with the same code using SQLite. What should I do? Get back to sqlite and risk database corruption?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload