revOpenDatabase Problem

Mike Bonner bonnmike at gmail.com
Mon Dec 26 17:09:51 EST 2011


Here, look here under 1.2 database header.
http://www.sqlite.org/fileformat2.html   Looks like the first 16 bytes of
the header are what you are looking for which are of course the first 16
bytes of the file.  Should be quick and easy to grab those bytes and
determine if the file is sqlite or not.

On Mon, Dec 26, 2011 at 3:05 PM, Mike Bonner <bonnmike at gmail.com> wrote:

> Hmm. don't have time to test it right this sec, but isn't an sqlite file
> pretty much a regular old text file? If so, it might be possible to open
> for read, read the first however much and check the file for validity.
> (even if its binary, surely there is a way to determine if its really an
> sqlite file) Would have to look up the sqlite file format but it seems like
> it should be possible.
>
>
> On Mon, Dec 26, 2011 at 3:00 PM, Pete <pete at mollysrevenge.com> wrote:
>
>> I think that's probably true.  I'm trying to figure out how to to tell if
>> a
>> real sqlite database was opened.  The first access to the db fails but the
>> error is "Undefined SQLite error" which is not very specific!
>>
>> This is in an app where the user can select an sqlite db so I'm at the
>> mercy of what they choose.  I did think about filtering the valid
>> extensions for the ask file dialog but it's my understanding that an
>> sqlite
>> db can have any extension.  I also tried calling revDatabaseType  but that
>> returns "SQLITE" even if it's not an sqlite database.
>>
>> Pete
>>
>> On Mon, Dec 26, 2011 at 1:42 PM, Mike Bonner <bonnmike at gmail.com> wrote:
>>
>> > My guess is that it doesn't check for a valid schema/format but that it
>> is
>> > only establishing a file handle which is successful. Then it should fail
>> > with an error on actual attempt to use.
>> >
>> > On Mon, Dec 26, 2011 at 2:33 PM, Pete <pete at mollysrevenge.com> wrote:
>> >
>> > > Using revOpenDatabase to open an sqlite database using a file that is
>> not
>> > > an sqlite database return an integer as if the database was
>> successfully
>> > > opened.  Any subsequent db accesses fail of course but I wonder why
>> > > revOpenDatabase doesn't return an error?
>> > >
>> > >
>> > > --
>> > > Pete
>> > > Molly's Revenge <http://www.mollysrevenge.com>
>> > > _______________________________________________
>> > > 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
>> > >
>> > _______________________________________________
>> > 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
>> >
>> >
>>
>>
>> --
>> Pete
>> Molly's Revenge <http://www.mollysrevenge.com>
>> _______________________________________________
>> 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