Question

I am actually using an old version of Realbasic (2008) and have been using VB Script to back up several small databases as Zip files.

I now find that thnis method doesn't work On Windows 8 and is also not cross-platform.

As I would like the backup to be in a single file so that it can be incremental, I though of using a large database to hold the copies of the smaller ones.

Is this possible?

I have no intention of buying a plug-in for this.

Was it helpful?

Solution

Similar to Pauls answer. You can read the binary data of the file you want to store into a MemoryBlock and then save the resulting string into the database. We've done this in several applications. Don't expect it to be speedy as all of that happens in RAM first and then gets written to the database.

Ideally, I think, you'd like to compress the file/string before saving. But there is no gzip built-in to Xojo so you'd have to result to using a 3rd party solution for compression or making an OS call via Declares.

OTHER TIPS

You can store anything as a BLOB in a SQLite table.

You might also consider a VirtualVolume and a BinaryStream to write the DB files into a single "container" file.

http://docs.xojo.com/index.php/VirtualVolume

Thanks to Paul and BKeeney for their help. BKeeney came closest and, after some experimentation, I have succeeded!

Here is what I did ...

      //
      Dim l, p As Integer
      Dim ReadFromFile as BinaryStream
      Dim f as FolderItem

      f= GetFolderItem("Keyhoe.db3")

      If f <> Nil Then
        l = f.Length
        ReadFromFile=f.OpenAsBinaryFile( False)

        mb = New MemoryBlock(l)

        While Not ReadFromFile.EOF
          mb.byte(p) = ReadFromFile.ReadInt8
          p = p + 1
        wend

        ReadFromFile.close
      End If

      Dim dbFile as FolderItem
      Dim db as REALSQLdatabase
      db= New REALSQLdatabase
      Dim mydate as New Date
      Dim rec as DatabaseRecord

      dbFile = GetFolderItem("Backup.db3")
      db.DatabaseFile = dbFile
      If db.Connect Then
        rec = New DatabaseRecord

        rec.Column("Name") = "Keyhoe"
        rec.BlobColumn("Content") = mb.LeftB(l)
        db.InsertRecord("Databases",rec)
        db.Commit
      else
        MsgBox "Error: "+db.ErrorMessage
      End if

      msgbox "Done..."

Thanks again ... all I have to do now is figure out how to get the databases back out but there are several examples for that task.

Cheers,

Alan ...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top