<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr">I'm having a heck of a time accessing an sqlite3 database file that's in the resource file.</div><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr"><br></div><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr">This doesn't throw an error:</div><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr" class="" style=""> dbFileName=':/pyqtdeploy_ptest1/testSqlite3.db'</div><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr" class="" style=""> qtDbFile=QtCore.QFile(dbFileName)</div><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr" class="" style="">So I know that the file exists and can be sen by the pyqt APIs</div><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr" class="" style=""><br></div><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr" class="" style="">But according to the tutorial we can't use the "standard Python file access functions"</div><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr" class="" style=""> <a href="http://pyqt.sourceforge.net/Docs/pyqtdeploy/tutorial.html" id="yui_3_16_0_1_1424734209765_2777" style="background-color: rgb(255, 255, 255);">http://pyqt.sourceforge.net/Docs/pyqtdeploy/tutorial.html</a></div><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr" class="" style="">So something like this is a no-no:</div><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr" class="" style=""> dbFileName=':/pyqtdeploy_ptest1/testSqlite3.db'<br></div><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr" class="" style=""> dbFile=open(dbFileName,'r')<br class="" style=""></div><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr" class="" style=""><br class="" style=""></div><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr" class="" style="">Unfortunately the sqlite3.connect() call takes a file name. </div><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr" class="" style=""><br></div><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr" class="" style="">I've tried with and without the ':' character. </div><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr" class="" style=""> conn = sqlite3.connect(":/pyqtdeploy_ptest1/testSqlite3.db?mode=ro")</div><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr" class="" style=""> conn = sqlite3.connect("/pyqtdeploy_ptest1/testSqlite3.db?mode=ro")</div><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr" class="" style="">I've even tried the uri argument approach:<br class="" style=""></div><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr" class="" style=""> conn = sqlite3.connect("file:/pyqtdeploy_ptest1/testSqlite3.db?mode=ro", uri=True)</div><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr" class="" style="">and with an extra ':' character:</div><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr" class="" style=""> conn = sqlite3.connect("file::/pyqtdeploy_ptest1/testSqlite3.db?mode=ro", uri=True)</div><div class="" style="" id="yui_3_16_0_1_1424734209765_3097"><br class="" style=""></div><div class="" style="" id="yui_3_16_0_1_1424734209765_3097" dir="ltr">The error I keep getting is:</div><div class="" style="" id="yui_3_16_0_1_1424734209765_3097" dir="ltr"> <span style="font-family: Monaco; font-size: 12pt;" class="" id="yui_3_16_0_1_1424734209765_3193">sqlite3.OperationalError: unable to open database file</span></div><div class="" style="" id="yui_3_16_0_1_1424734209765_3097" dir="ltr"><span style="font-family: Monaco; font-size: 12pt;" class=""><br></span></div>
<div id="yui_3_16_0_1_1424734209765_2680" dir="ltr" class="" style=""> I've thought about using QFile, getting the file descriptor and then copying the file to the IPad's /tmp directory but that's my last resort.</div><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr" class="" style=""><br></div><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr" class="" style="">What would be the proper way to open the sqlite3 database?</div><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr" class="" style=""><br></div><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr" class="" style="">Thanks,</div><div id="yui_3_16_0_1_1424734209765_2680" dir="ltr" class="" style="">Michael</div></div></body></html>