Error connecting to SQLlite in iOS

Mike Bonner bonnmike at gmail.com
Thu Apr 20 14:51:41 EDT 2017


Unless things have changed, when you add files using the copy files pane of
the standalone settings, when sent to ios or android they end up in the
engine folder. (I think?  Or somewhere in that hierarchy)
You would need to check for the existence of the file in documents on app
startup and if it doesn't exist, copy it from engine to where you need it
to be in the documents folder.


   - "engine": The folder containing the built standalone engine (i.e. the
   bundle). This is useful for constructing paths to resources that have
   been copied into thebundle at build time

I don't recall if copied files appear in the toplevel or not, but it
shouldn't be too difficult to find where it is.

Another option would be to put the initial database into a property rather
than from copy files and place it into the documents folder from there.

On Thu, Apr 20, 2017 at 11:37 AM, JOHN PATTEN via use-livecode <
use-livecode at lists.runrev.com> wrote:

> Hi All,
>
> I have a simple project that uses an sql lite database. It works fine in
> LiveCode, but when I test it in the iOS simulator, i get an error.
>
> I have copied to the SQL.lite database to the “Copy Files” in the
> standalone settings. I have also added the SqLite and MySQL inclusions.
>
> Here is the link to the project and db: Here is a link to the stack and
> sql db:  https://www.dropbox.com/s/74rhx88dod6cs2k/CCSS%20App.zip?dl=0 <
> https://www.dropbox.com/s/74rhx88dod6cs2k/CCSS%20App.zip?dl=0>
>
> Here is the script I am using.
>
> local sDatabaseID
>
> command databaseConnect
> local tDatabasePath, tDatabaseID
>
>      put specialFolderPath("Documents") &  "/ccssdb-ela.sqlite" into
> tDatabasePath
>
> ## Test if a database exists
>
> if there is a file tDatabasePath then
>
> answer "A database already exists" with "Okay"
>
> end if
>
> if there is a file tDatabasepath then
> put  revOpenDatabase("sqlite", tDatabasePath, , , , ) into tDatabaseID
> setDatabaseID tDatabaseID
>
> put cd fld "targetGrade" into tGrade
>
> if tGrade is 10 then
>
> put 9 into tGrade
>
> end if
>
> if tGrade is 12 then
>
> put 11 into tGrade
>
> end if
>
> put revQueryDatabase(tDatabaseID,"SELECT * FROM ccss_data WHERE grade
> =:1","tGrade") into theCursor
>
> if theCursor is an integer then
>
> ConvertSQLCursorToArray theCursor, theDataGridArray
>
> put the result into theError
>
> if theError is empty then
>
> set the dgData of group "ccss_data" to theDataGridArray
>
> end if
>
> revCloseCursor theCursor
>
>
> revCloseDatabase tDatabaseID
>
> else
>
>
> Answer "Error connecting to the database:" && tDatabaseID & "."
> end if
>
>
> else
>
> Answer "Having trouble locating database."
>
> end if
>
> end DatabaseConnect
>
> command setDatabaseID pDatabaseID
>
>   put pDatabaseID into sDatabaseID
>
> end setDatabaseID
>
>
> function getDatabaseID
>
>   return sDatabaseID
>
> end getDatabaseID
>
>
> command ConvertSQLCursorToArray pCursor, @pOutArrayA
>
> local i
>
> local theFields
>
> local theError
>
>
> put revDatabaseColumnNames(pCursor) into theFields
>
> if theFields begins with "revdberr," then
>
> put item 2 to -1 of theFields into theError
>
> end if
>
> if theError is empty then
>
> put 0 into i
>
> repeat until revQueryIsAtEnd(pCursor)
>
> add 1 to i
>
>
> repeat for each item theField in theFields
>
> put revDatabaseColumnNamed(pCursor, theField) into pOutArrayA [i]
> [theField]
>
> end repeat
>
>
> revMoveToNextRecord pCursor
>
> end repeat
>
> end if
>
> return theError
>
> end ConvertSQLCursorToArray
>
>
> Thank you!
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode



More information about the use-livecode mailing list