Tabloyu aDB'den başka bir bDB'ye kopyalamak istiyorum.Tablo bir db diğerine kopyalanıyor db
Bu yüzden bir yöntem yaptım. Açık 2 veritabanını ve Ekleme sorgusunu kullanmanın işe yarayacağını düşünüyorum, ancak ayrıntı yolunu bilmiyorum.
-(void)copyDatabaseTableSoruceFileName:(NSString *)source CopyFileName:(NSString *)copy
{
sqlite3 *sourceDatabase=NULL;
sqlite3 *copyDatabase=NULL;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);
NSString* documentDir = [paths objectAtIndex:0];
//source
[self copyFileIfNeed:source path:documentDir];
NSString *SourceDBPath = [documentDir stringByAppendingPathComponent:source];
if(sqlite3_open([SourceDBPath UTF8String],&sourceDatabase)!= SQLITE_OK)
{
NSLog(@"DB File Open Error :%@", SourceDBPath);
sourceDatabase = NULL;
}
//copy
[self copyFileIfNeed:copy path:documentDir];
NSString *CopyDBPath = [documentDir stringByAppendingPathComponent:copy];
if(sqlite3_open([CopyDBPath UTF8String],©Database)!= SQLITE_OK)
{
NSLog(@"DB File Open Error :%@", CopyDBPath);
copyDatabase = NULL;
}
//source to copy
// How in this area?
}
ve daha fazla nasıl yapılır? // kopyalanacak alan. sqlite3 içinde
+1 bana hızlı tablo oluşturma hatırlatmak & ile kopyalamak için "aDB.oldTableInMyOtherDB AS SELECT * FROM TABLO newTableInDB1 CREATE;" –
iyi açıkladı. ios objc beton kodunda yazabilirseniz harika olur. – OMGPOP
Komutlar salt SQL'dir, bunları sqlite3_exec() çağrısı ile yürütürsünüz. – Zuppa