PDA

View Full Version : Where in the world is the SQLite database file?




wyattbiker
Mar 14, 2009, 07:35 PM
I am using the Safari to create a web based database using javascript . The page executes succesfully creating a database and tables. Now I try to find the db file on the mac OS X 10.5. Anyone know where to look? Thanks

Here is a sample from apples website:



alert ("I am ready to run");
var shortName = 'mydatabase.db';
var version = '1.0';

var displayName = 'My Important Database';

var maxSize = 65536; // in bytes

var mydb = openDatabase(shortName, version, displayName, maxSize);



yayaba
Mar 15, 2009, 02:11 AM
If you're on the iPhone simulator mine is in:

~/Library/Application Support/iPhone Simulator/User/Applications

Then there is a long ID string. Multiple runs of your program create a new one so the easiest way to find out is to just print out the filename of your db in your program via NSLog. For example, I print out my location like this:


NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"expenses.sqlite"];
NSLog([NSString stringWithFormat:@"SQLite file is at %@", path]);
sqlite3_open([path UTF8String], &database);

wyattbiker
Mar 16, 2009, 01:06 PM
If you're on the iPhone simulator mine is in:

~/Library/Application Support/iPhone Simulator/User/Applications

Then there is a long ID string. Multiple runs of your program create a new one so the easiest way to find out is to just print out the filename of your db in your program via NSLog. For example, I print out my location like this:


NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"expenses.sqlite"];
NSLog([NSString stringWithFormat:@"SQLite file is at %@", path]);
sqlite3_open([path UTF8String], &database);



Thank you. And yes, I found them under funny names.

tskoti
Apr 1, 2009, 03:17 PM
hi,

Plz tell me how to create a file with testFileName.sqlite in MAC, and also, how to create a file which is encoded (UTF8String) format.

Thanks in Advance,
Koti