<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"><meta name="Generator" content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:"Courier New";}
span.pln
        {mso-style-name:pln;}
span.pun
        {mso-style-name:pun;}
span.kwd
        {mso-style-name:kwd;}
span.lit
        {mso-style-name:lit;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style></head><body lang="EN-US" link="blue" vlink="purple"><div class="WordSection1"><p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:12.0pt;font-family:"Times New Roman","serif"">Greetings,</span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:12.0pt;font-family:"Times New Roman","serif"">Using PyQt, I am having a problem inserting Nulls into a MySql table using the execBatch() method of QSqlQuery. From the documentation, a null QVariant (i.e. QVariant(QVariant.Double)) represents a Null when inserting.  When doing a regular query.exec_ it does actually insert Nulls, however when I do a query.execBatch(), zeros get inserted, not Nulls.</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">query.prepare(INSERT INTO `table` VALUES (?, ?))<br><br>var1=[1.0, QVariant(QVariant.Double)]<br>var2=[QVariant(QVariant.Double), 32.6]<br>
<br>query.addBindValue(QVariant(var1))<br>query.addBindValue(QVariant(var2))<br>query.execBatch()</span></p><p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:12.0pt;font-family:"Times New Roman","serif"">With the above code, I would expect this to be inserted (Nulls should appear where QVariant objects in the lists are): </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">1.0  Null<br>Null 32.6</span></p><p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:12.0pt;font-family:"Times New Roman","serif"">Instead what actually gets inserted is:</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">1.0 0<br>0   32.6</span></p><p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:12.0pt;font-family:"Times New Roman","serif"">If I were to insert this line by line using just regular exec_ it would work, but I would rather use execBatch as I have many rows to insert at once (above is just an example). I have tried making every item in the lists a QVariant, whether Null or not, but I still get zeros, and I cannot pass in anything other than a QVariant to addBindValue (which I why I wrap the list in one when I call the method).</span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:12.0pt;font-family:"Times New Roman","serif"">Any help would be greatly appreciated. Thank you.</span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:12.0pt;font-family:"Times New Roman","serif"">Mark</span></p><p class="MsoNormal"> </p></div></body></html>