IOS中sqlite的update操作无效

-(BOOL)updateDevice:(device*) dev{
if([self isDeviceExist:dev]){
sqlite3_stmt *statement;
//1 数据库地址
const char *dbpath = [_databasePath UTF8String];
//2 打开数据库
if (sqlite3_open(dbpath, &_dataBase)==SQLITE_OK) {
//3 数据库语句准备
NSString *insertSql = [NSString stringWithFormat:@"update device set DeviceName = \"%@\",Light1Name = \"%@\", Light2Name = \"%@\" ,Light3Name = \"%@\" where MID = \"%@\"",dev.DeviceName,dev.Light1Name,dev.Light2Name,dev.Light3Name,dev.MID];
NSLog(@"%@",insertSql);

        const char *insertsatement = [insertSql UTF8String];
        NSLog(@"the char :%s",insertsatement);
        if(sqlite3_prepare_v2(_dataBase, insertsatement, -1, &statement, NULL)==SQLITE_OK){
        //4 执行数据语句
        int result=sqlite3_step(statement);
        if (result==SQLITE_DONE) {

            NSLog(@"update success");
            sqlite3_finalize(statement);
            sqlite3_close(_dataBase);
            return YES;
        }else{
            NSLog(@"update failed!");
            sqlite3_finalize(statement);
        }
        }
    }
}else{
    NSLog(@"device is exist");

}
NSLog(@"Error:%s",sqlite3_errmsg(_dataBase));
sqlite3_close(_dataBase);
return NO;

}

代码如上,update的sql语句在sqlite中测试没问题,可是在实机上测试的时候代码执行没有报错,可是数据没有更新,求解

2个回答

如果在模拟器上可以更新,在真机上不行,那应该就是访问权限的问题
你先看看数据库路径,是不是放到沙箱内了,可写的文件要放在document或者library里面,不能放mainBundle里

真机上数据库连接不对!

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
IOS,SQLite批量插入错误

在数据库中插入数据的时候,报错:`Prepare-error library routine called out of sequence` 代码如下,麻烦帮我看看错误出在哪儿了。谢谢 NSString *databaseName = @"DB.sqlite"; NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); NSString *documentsDir = [documentPaths objectAtIndex:0]; NSString *databasePath = [documentsDir stringByAppendingPathComponent:databaseName]; sqlite3 *concertsDB; const char *dbpath = [databasePath UTF8String]; if (sqlite3_open(dbpath, &concertsDB) == SQLITE_OK) { sqlite3_exec(concertsDB, "BEGIN TRANSACTION", 0, 0, 0); const char *sqlStatement = "INSERT INTO concertsData VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; sqlite3_stmt *compiledStatement; if (sqlite3_prepare_v2(concertsDB, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) { int hasError; for (int i=0; i<[events count]; i++) { sqlite3_bind_text(compiledStatement, 1, [[[events objectAtIndex:i] title] UTF8String], -1, SQLITE_TRANSIENT); sqlite3_bind_int(compiledStatement, 2, [[[events objectAtIndex:i] date] timeIntervalSince1970]); sqlite3_bind_text(compiledStatement, 3, [[[events objectAtIndex:i] time] UTF8String], -1, SQLITE_TRANSIENT); sqlite3_bind_text(compiledStatement, 4, [[[events objectAtIndex:i] shortDesription] UTF8String], -1, SQLITE_TRANSIENT); sqlite3_bind_text(compiledStatement, 5, [[[events objectAtIndex:i] conductor] UTF8String], -1, SQLITE_TRANSIENT); sqlite3_bind_text(compiledStatement, 6, [[[events objectAtIndex:i] location] UTF8String], -1, SQLITE_TRANSIENT); sqlite3_bind_text(compiledStatement, 7, [[[events objectAtIndex:i] durations] UTF8String], -1, SQLITE_TRANSIENT); sqlite3_bind_text(compiledStatement, 8, [[[events objectAtIndex:i] works] UTF8String], -1, SQLITE_TRANSIENT); sqlite3_bind_text(compiledStatement, 9, [[[events objectAtIndex:i] solists] UTF8String], -1, SQLITE_TRANSIENT); sqlite3_bind_text(compiledStatement, 10, [[[events objectAtIndex:i] fulltext] UTF8String], -1, SQLITE_TRANSIENT); sqlite3_bind_text(compiledStatement, 11, [[[[events objectAtIndex:i] concertUrl] absoluteString] UTF8String], -1, SQLITE_TRANSIENT); sqlite3_bind_text(compiledStatement, 12, [[[[events objectAtIndex:i] buyUrl] absoluteString] UTF8String], -1, SQLITE_TRANSIENT); sqlite3_bind_text(compiledStatement, 13, [[[events objectAtIndex:i] imageName] UTF8String], -1, SQLITE_TRANSIENT); if (sqlite3_step(compiledStatement) != SQLITE_DONE) { hasError=1; NSLog(@"Prepare-error %s", sqlite3_errmsg(concertsDB)); } sqlite3_clear_bindings(compiledStatement); } sqlite3_reset(compiledStatement); if( hasError == 0 ) { sqlite3_exec(concertsDB, "COMMIT", 0, 0, 0); } else { sqlite3_exec(concertsDB, "ROLLBACK", 0, 0, 0); } } sqlite3_close(concertsDB); }

ios中SQLite和core data使用求解

本人ios开发小白一枚,有几点疑问想咨询一下ios开发前辈。 第一:在ios app开发中,什么类型的应用会用到SQLite或者core data; 第二:已经在运营中的电商类型的网站,数据库使用的是mysql,现在需要开发ios的app,app端的数据应该怎么和服务器进行通信呢?登陆,下单,支付等操作时的通信怎么才能保证数据传输的安全性呢?

iOS使用SQLite数据库,频繁打开和关闭数据库有损性能。我能不能打开数据库之后一直不关闭呢?

程序一启动我就打开数据库,然后再也不管他,这样可以吗?你们都是在什么时候打开什么时候关闭的?

【Android】SQLite执行Update语句没结果

数据库存在,且有数据,但是执行Update语句后没结果。 ContentValues value = new ContentValues(); value.put(key,value); String[] args = {args}; DB.update(table_name ,value, "phone=?", args); 执行后没反应

androd sqlite update 语句不执行

单独更新imagepath字段语句执行没有效果。imagepath和description一起更新就有效果,为什么? 代码: String sql = "update t_pattern set name = ? ,userid = ?,description=?, imagePath = ? where _id = ?"; db.execSQL(sql, new Object[] { sInstance.getName(), sInstance.getUserid(), sInstance.getDescription(), sInstance.getImgPath(), sInstance.getId() }); 表创建代码: sql = "create table t_pattern (_id integer primary key autoincrement,name text default ('name'),userid integer,description text default ('description'),devicenum integer default(0),imagePath TEXT)"; db.execSQL(sql);

ios 中应用sqlite3进行本地读取 每次读取 ios内存增加知道内存不足 崩溃

sqlite3_stmt *stmt = [[BISQLiteUtil sharedBISQLiteUtil] getSQLiteStatement:(char *)[sql UTF8String]]; 1.这段代码注释内存增加没问题, 2.一释放,读取的数据不做处理,内存也会明显增加,操作几次,知道系统内存不足崩溃退出 3.sqlite3读取数据有什么优化方法吗?有人遇到过这个问题吗?急。。。。

IOS的SQLite查询数据,如果没有对应数据的话,应该怎么获取到这个信息

RT,求解。 我是用本地的数据库,数据都是已经固定了的,根据编号显示数据,如果数据中没有编号,我想设置弹出一个提示,但是我不知道怎么获取查不到数据的这个信息

sqlite数据库怎么循环update 语句

android sqlite数据库有一给字段,这个字段里面是null没有值,点击某些操作后我现在需要在代码中循环给这个字段写入数字序号0,1,2,3,4,5,6这样的顺序 ,我的update 语句怎么写,循环是不是直接 for里面直接i就可以了 谢谢

iOS APP升级之后,APP的.sqlite文本会更新吗?增加了新字段

新的APP的.sqlite文件添加了新字段,这样貌似会跟存在本地的sqlite文件发生冲突,请问该怎么解决?

IOS本地SQLite数据库,虚拟测试可以读取,真机测试连接不上

RT,项目用的本地数据库文件,转存到沙盒中读取,在虚拟机上运行可以,真机调试时候连接不上,求解 还有就是打包项目时候怎么把数据库也一起打包进去?

ios 用swift语言的,然后链接数据库,sqlite。

ios开发,用是swift语言。如何链接SQLite数据库。求详细代码

提高 SQLite 的每秒插入性能?

<div class="post-text" itemprop="text"> <p>Optimizing SQLite is tricky. Bulk-insert performance of a C application can vary from 85 inserts per second to over 96,000 inserts per second!</p> <p><strong>Background:</strong> We are using SQLite as part of a desktop application. We have large amounts of configuration data stored in XML files that are parsed and loaded into an SQLite database for further processing when the application is initialized. SQLite is ideal for this situation because it's fast, it requires no specialized configuration, and the database is stored on disk as a single file.</p> <p><strong>Rationale:</strong> <em>Initially I was disappointed with the performance I was seeing.</em> It turns-out that the performance of SQLite can vary significantly (both for bulk-inserts and selects) depending on how the database is configured and how you're using the API. It was not a trivial matter to figure out what all of the options and techniques were, so I thought it prudent to create this community wiki entry to share the results with Stack Overflow readers in order to save others the trouble of the same investigations.</p> <p><strong>The Experiment:</strong> Rather than simply talking about performance tips in the general sense (i.e. <em>"Use a transaction!"</em>), I thought it best to write some C code and <em>actually measure</em> the impact of various options. We're going to start with some simple data:</p> <ul> <li>A 28 MB TAB-delimited text file (approximately 865,000 records) of the <a href="http://www.toronto.ca/open/datasets/ttc-routes" rel="noreferrer">complete transit schedule for the city of Toronto</a></li> <li>My test machine is a 3.60 GHz P4 running Windows XP.</li> <li>The code is compiled with <a href="http://en.wikipedia.org/wiki/Visual_C%2B%2B#32-bit_versions" rel="noreferrer">Visual C++</a> 2005 as "Release" with "Full Optimization" (/Ox) and Favor Fast Code (/Ot).</li> <li>I'm using the SQLite "Amalgamation", compiled directly into my test application. The SQLite version I happen to have is a bit older (3.6.7), but I suspect these results will be comparable to the latest release (please leave a comment if you think otherwise).</li> </ul> <p><em>Let's write some code!</em></p> <p><strong>The Code:</strong> A simple C program that reads the text file line-by-line, splits the string into values and then will inserts the data into an SQLite database. In this "baseline" version of the code, the database is created, but we won't actually insert data:</p> <pre><code>/************************************************************* Baseline code to experiment with SQLite performance. Input data is a 28 MB TAB-delimited text file of the complete Toronto Transit System schedule/route info from http://www.toronto.ca/open/datasets/ttc-routes/ **************************************************************/ #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;time.h&gt; #include &lt;string.h&gt; #include "sqlite3.h" #define INPUTDATA "C:\\TTC_schedule_scheduleitem_10-27-2009.txt" #define DATABASE "c:\\TTC_schedule_scheduleitem_10-27-2009.sqlite" #define TABLE "CREATE TABLE IF NOT EXISTS TTC (id INTEGER PRIMARY KEY, Route_ID TEXT, Branch_Code TEXT, Version INTEGER, Stop INTEGER, Vehicle_Index INTEGER, Day Integer, Time TEXT)" #define BUFFER_SIZE 256 int main(int argc, char **argv) { sqlite3 * db; sqlite3_stmt * stmt; char * sErrMsg = 0; char * tail = 0; int nRetCode; int n = 0; clock_t cStartClock; FILE * pFile; char sInputBuf [BUFFER_SIZE] = "\0"; char * sRT = 0; /* Route */ char * sBR = 0; /* Branch */ char * sVR = 0; /* Version */ char * sST = 0; /* Stop Number */ char * sVI = 0; /* Vehicle */ char * sDT = 0; /* Date */ char * sTM = 0; /* Time */ char sSQL [BUFFER_SIZE] = "\0"; /*********************************************/ /* Open the Database and create the Schema */ sqlite3_open(DATABASE, &amp;db); sqlite3_exec(db, TABLE, NULL, NULL, &amp;sErrMsg); /*********************************************/ /* Open input file and import into Database*/ cStartClock = clock(); pFile = fopen (INPUTDATA,"r"); while (!feof(pFile)) { fgets (sInputBuf, BUFFER_SIZE, pFile); sRT = strtok (sInputBuf, "\t"); /* Get Route */ sBR = strtok (NULL, "\t"); /* Get Branch */ sVR = strtok (NULL, "\t"); /* Get Version */ sST = strtok (NULL, "\t"); /* Get Stop Number */ sVI = strtok (NULL, "\t"); /* Get Vehicle */ sDT = strtok (NULL, "\t"); /* Get Date */ sTM = strtok (NULL, "\t"); /* Get Time */ /* ACTUAL INSERT WILL GO HERE */ n++; } fclose (pFile); printf("Imported %d records in %4.2f seconds\n", n, (clock() - cStartClock) / (double)CLOCKS_PER_SEC); sqlite3_close(db); return 0; } </code></pre> <hr> <h2>The "Control"</h2> <p>Running the code as-is doesn't actually perform any database operations, but it will give us an idea of how fast the raw C file I/O and string processing operations are.</p> <blockquote> <p>Imported 864913 records in 0.94 seconds</p> </blockquote> <p>Great! We can do 920,000 inserts per second, provided we don't actually do any inserts :-)</p> <hr> <h2>The "Worst-Case-Scenario"</h2> <p>We're going to generate the SQL string using the values read from the file and invoke that SQL operation using sqlite3_exec:</p> <pre><code>sprintf(sSQL, "INSERT INTO TTC VALUES (NULL, '%s', '%s', '%s', '%s', '%s', '%s', '%s')", sRT, sBR, sVR, sST, sVI, sDT, sTM); sqlite3_exec(db, sSQL, NULL, NULL, &amp;sErrMsg); </code></pre> <p>This is going to be slow because the SQL will be compiled into VDBE code for every insert and every insert will happen in its own transaction. <em>How slow?</em></p> <blockquote> <p>Imported 864913 records in 9933.61 seconds</p> </blockquote> <p>Yikes! 2 hours and 45 minutes! That's only <strong>85 inserts per second.</strong></p> <h2>Using a Transaction</h2> <p>By default, SQLite will evaluate every INSERT / UPDATE statement within a unique transaction. If performing a large number of inserts, it's advisable to wrap your operation in a transaction:</p> <pre><code>sqlite3_exec(db, "BEGIN TRANSACTION", NULL, NULL, &amp;sErrMsg); pFile = fopen (INPUTDATA,"r"); while (!feof(pFile)) { ... } fclose (pFile); sqlite3_exec(db, "END TRANSACTION", NULL, NULL, &amp;sErrMsg); </code></pre> <blockquote> <p>Imported 864913 records in 38.03 seconds</p> </blockquote> <p>That's better. Simply wrapping all of our inserts in a single transaction improved our performance to <strong>23,000 inserts per second.</strong></p> <h2>Using a Prepared Statement</h2> <p>Using a transaction was a huge improvement, but recompiling the SQL statement for every insert doesn't make sense if we using the same SQL over-and-over. Let's use <code>sqlite3_prepare_v2</code> to compile our SQL statement once and then bind our parameters to that statement using <code>sqlite3_bind_text</code>:</p> <pre><code>/* Open input file and import into the database */ cStartClock = clock(); sprintf(sSQL, "INSERT INTO TTC VALUES (NULL, @RT, @BR, @VR, @ST, @VI, @DT, @TM)"); sqlite3_prepare_v2(db, sSQL, BUFFER_SIZE, &amp;stmt, &amp;tail); sqlite3_exec(db, "BEGIN TRANSACTION", NULL, NULL, &amp;sErrMsg); pFile = fopen (INPUTDATA,"r"); while (!feof(pFile)) { fgets (sInputBuf, BUFFER_SIZE, pFile); sRT = strtok (sInputBuf, "\t"); /* Get Route */ sBR = strtok (NULL, "\t"); /* Get Branch */ sVR = strtok (NULL, "\t"); /* Get Version */ sST = strtok (NULL, "\t"); /* Get Stop Number */ sVI = strtok (NULL, "\t"); /* Get Vehicle */ sDT = strtok (NULL, "\t"); /* Get Date */ sTM = strtok (NULL, "\t"); /* Get Time */ sqlite3_bind_text(stmt, 1, sRT, -1, SQLITE_TRANSIENT); sqlite3_bind_text(stmt, 2, sBR, -1, SQLITE_TRANSIENT); sqlite3_bind_text(stmt, 3, sVR, -1, SQLITE_TRANSIENT); sqlite3_bind_text(stmt, 4, sST, -1, SQLITE_TRANSIENT); sqlite3_bind_text(stmt, 5, sVI, -1, SQLITE_TRANSIENT); sqlite3_bind_text(stmt, 6, sDT, -1, SQLITE_TRANSIENT); sqlite3_bind_text(stmt, 7, sTM, -1, SQLITE_TRANSIENT); sqlite3_step(stmt); sqlite3_clear_bindings(stmt); sqlite3_reset(stmt); n++; } fclose (pFile); sqlite3_exec(db, "END TRANSACTION", NULL, NULL, &amp;sErrMsg); printf("Imported %d records in %4.2f seconds\n", n, (clock() - cStartClock) / (double)CLOCKS_PER_SEC); sqlite3_finalize(stmt); sqlite3_close(db); return 0; </code></pre> <blockquote> <p>Imported 864913 records in 16.27 seconds</p> </blockquote> <p>Nice! There's a little bit more code (don't forget to call <code>sqlite3_clear_bindings</code> and <code>sqlite3_reset</code>), but we've more than doubled our performance to <strong>53,000 inserts per second.</strong></p> <h2>PRAGMA synchronous = OFF</h2> <p>By default, SQLite will pause after issuing a OS-level write command. This guarantees that the data is written to the disk. By setting <code>synchronous = OFF</code>, we are instructing SQLite to simply hand-off the data to the OS for writing and then continue. There's a chance that the database file may become corrupted if the computer suffers a catastrophic crash (or power failure) before the data is written to the platter:</p> <pre><code>/* Open the database and create the schema */ sqlite3_open(DATABASE, &amp;db); sqlite3_exec(db, TABLE, NULL, NULL, &amp;sErrMsg); sqlite3_exec(db, "PRAGMA synchronous = OFF", NULL, NULL, &amp;sErrMsg); </code></pre> <blockquote> <p>Imported 864913 records in 12.41 seconds</p> </blockquote> <p>The improvements are now smaller, but we're up to <strong>69,600 inserts per second.</strong></p> <h2>PRAGMA journal_mode = MEMORY</h2> <p>Consider storing the rollback journal in memory by evaluating <code>PRAGMA journal_mode = MEMORY</code>. Your transaction will be faster, but if you lose power or your program crashes during a transaction you database could be left in a corrupt state with a partially-completed transaction:</p> <pre><code>/* Open the database and create the schema */ sqlite3_open(DATABASE, &amp;db); sqlite3_exec(db, TABLE, NULL, NULL, &amp;sErrMsg); sqlite3_exec(db, "PRAGMA journal_mode = MEMORY", NULL, NULL, &amp;sErrMsg); </code></pre> <blockquote> <p>Imported 864913 records in 13.50 seconds</p> </blockquote> <p>A little slower than the previous optimization at <strong>64,000 inserts per second.</strong></p> <h2>PRAGMA synchronous = OFF <em>and</em> PRAGMA journal_mode = MEMORY</h2> <p>Let's combine the previous two optimizations. It's a little more risky (in case of a crash), but we're just importing data (not running a bank):</p> <pre><code>/* Open the database and create the schema */ sqlite3_open(DATABASE, &amp;db); sqlite3_exec(db, TABLE, NULL, NULL, &amp;sErrMsg); sqlite3_exec(db, "PRAGMA synchronous = OFF", NULL, NULL, &amp;sErrMsg); sqlite3_exec(db, "PRAGMA journal_mode = MEMORY", NULL, NULL, &amp;sErrMsg); </code></pre> <blockquote> <p>Imported 864913 records in 12.00 seconds</p> </blockquote> <p>Fantastic! We're able to do <strong>72,000 inserts per second.</strong></p> <h2>Using an In-Memory Database</h2> <p>Just for kicks, let's build upon all of the previous optimizations and redefine the database filename so we're working entirely in RAM:</p> <pre><code>#define DATABASE ":memory:" </code></pre> <blockquote> <p>Imported 864913 records in 10.94 seconds</p> </blockquote> <p>It's not super-practical to store our database in RAM, but it's impressive that we can perform <strong>79,000 inserts per second.</strong></p> <h2>Refactoring C Code</h2> <p>Although not specifically an SQLite improvement, I don't like the extra <code>char*</code> assignment operations in the <code>while</code> loop. Let's quickly refactor that code to pass the output of <code>strtok()</code> directly into <code>sqlite3_bind_text()</code>, and let the compiler try to speed things up for us:</p> <pre><code>pFile = fopen (INPUTDATA,"r"); while (!feof(pFile)) { fgets (sInputBuf, BUFFER_SIZE, pFile); sqlite3_bind_text(stmt, 1, strtok (sInputBuf, "\t"), -1, SQLITE_TRANSIENT); /* Get Route */ sqlite3_bind_text(stmt, 2, strtok (NULL, "\t"), -1, SQLITE_TRANSIENT); /* Get Branch */ sqlite3_bind_text(stmt, 3, strtok (NULL, "\t"), -1, SQLITE_TRANSIENT); /* Get Version */ sqlite3_bind_text(stmt, 4, strtok (NULL, "\t"), -1, SQLITE_TRANSIENT); /* Get Stop Number */ sqlite3_bind_text(stmt, 5, strtok (NULL, "\t"), -1, SQLITE_TRANSIENT); /* Get Vehicle */ sqlite3_bind_text(stmt, 6, strtok (NULL, "\t"), -1, SQLITE_TRANSIENT); /* Get Date */ sqlite3_bind_text(stmt, 7, strtok (NULL, "\t"), -1, SQLITE_TRANSIENT); /* Get Time */ sqlite3_step(stmt); /* Execute the SQL Statement */ sqlite3_clear_bindings(stmt); /* Clear bindings */ sqlite3_reset(stmt); /* Reset VDBE */ n++; } fclose (pFile); </code></pre> <p><strong>Note: We are back to using a real database file. In-memory databases are fast, but not necessarily practical</strong></p> <blockquote> <p>Imported 864913 records in 8.94 seconds</p> </blockquote> <p>A slight refactoring to the string processing code used in our parameter binding has allowed us to perform <strong>96,700 inserts per second.</strong> I think it's safe to say that this is <em>plenty fast</em>. As we start to tweak other variables (i.e. page size, index creation, etc.) this will be our benchmark.</p> <hr> <h2>Summary (so far)</h2> <p><em>I hope you're still with me!</em> The reason we started down this road is that bulk-insert performance varies so wildly with SQLite, and it's not always obvious what changes need to be made to speed-up our operation. Using the same compiler (and compiler options), the same version of SQLite and the same data we've optimized our code and our usage of SQLite to go <strong>from a worst-case scenario of 85 inserts per second to over 96,000 inserts per second!</strong></p> <hr> <h2>CREATE INDEX then INSERT vs. INSERT then CREATE INDEX</h2> <p>Before we start measuring <code>SELECT</code> performance, we know that we'll be creating indexes. It's been suggested in one of the answers below that when doing bulk inserts, it is faster to create the index after the data has been inserted (as opposed to creating the index first then inserting the data). Let's try:</p> <p><strong>Create Index then Insert Data</strong></p> <pre><code>sqlite3_exec(db, "CREATE INDEX 'TTC_Stop_Index' ON 'TTC' ('Stop')", NULL, NULL, &amp;sErrMsg); sqlite3_exec(db, "BEGIN TRANSACTION", NULL, NULL, &amp;sErrMsg); ... </code></pre> <blockquote> <p>Imported 864913 records in 18.13 seconds</p> </blockquote> <p><strong>Insert Data then Create Index</strong></p> <pre><code>... sqlite3_exec(db, "END TRANSACTION", NULL, NULL, &amp;sErrMsg); sqlite3_exec(db, "CREATE INDEX 'TTC_Stop_Index' ON 'TTC' ('Stop')", NULL, NULL, &amp;sErrMsg); </code></pre> <blockquote> <p>Imported 864913 records in 13.66 seconds</p> </blockquote> <p>As expected, bulk-inserts are slower if one column is indexed, but it does make a difference if the index is created after the data is inserted. Our no-index baseline is 96,000 inserts per second. <strong>Creating the index first then inserting data gives us 47,700 inserts per second, whereas inserting the data first then creating the index gives us 63,300 inserts per second.</strong></p> <hr> <p>I'd gladly take suggestions for other scenarios to try... And will be compiling similar data for SELECT queries soon.</p> </div> <p>转载于:https://stackoverflow.com/questions/1711631/improve-insert-per-second-performance-of-sqlite</p>

更新sqlite数据库的问题

需要更新detail viewcontroller中textfield的记录。但是点击了更新按钮,会更新失败。 -(IBAction)updateQuery:(id)sender { sqlite3_stmt *statement; const char *dbpath = [databasePath UTF8String]; if (sqlite3_open(dbpath, &Information) == SQLITE_OK) { NSString *updateSQL = [NSString stringWithFormat: @"update CONTACTS set address=\"%@\",phone=\"%@\",imageUrl=\"%@\" WHERE name=\"%@\"",daddress.text,dphone.text,durl.text,dname.text]; const char *update_stmt = [updateSQL UTF8String]; sqlite3_prepare_v2(Information, update_stmt, -1, &statement, NULL); if (sqlite3_step(statement) == SQLITE_DONE) { dstatuslabel.text=@"updated successfully"; } else { dstatuslabel.text = @"Failed to update contact"; } sqlite3_finalize(statement); sqlite3_close(Information); } }

关于sqlite3.24版本对数据库做更新操作被锁的问题

最近项目对sqlite版本做了更新,更新到了3.24,本来没有bug的项目现在出现了bug,本来的其中一个功能是要对项目的数据进行更新,需要同时更新多个数据,其中一个MAIN数据库需要其他的数据库都attach到这个数据库上,单线程下做更新时没有问题,但是双线程下更新时,更新到MAIN数据库时就会报错(此时其他数据库已经全班正常更新完成),错误是“database is busy”,请问有谁用过最新版的sqlite3吗?有没有碰到相同问题解决了的?

ios中sql查询及取数字最大值

表名:inventory 字段sheetCode ,字段sheetCode的内容分别是552, 275, cs587, be78g, 9h87, 87gb, 998, 276 如上:请问怎么用sql语句查询纯数字最大值,即查询结果998

Javascript操作SQLite中的函数执行问题

首先是现有的问题描述—— **当前流程** 我通过Ajax取到一组数据,然后在Ajax的回调函数中,操作SQLite,如果本地数据库中(通过ID查找)没有这组数据,就Insert;如果有,就更新本地数据库里的条目。 **存在问题** 我的Insert方法是可以正常运行的。但是Update方法就会在实际运行时直接被跳过。 **核心代码如下** ```javascript db.transaction(function(con){ con.executeSql('SELECT * FROM ' + uname + ' WHERE appid=' + APP_ID,[],function(con,res){ if(res.rows.length <= 0){//如果有数据 addData(uname, APP_ID, 1, 0, APP_NAME_CN, ICON_PATH, VERSION, APP_COMPANY, ACTIVITY.toLowerCase());} else{//没有数据 isDown = (res.rows.item(0).isDown == 1); sql = 'UPDATE ' + uname + ' SET name = "' + APP_NAME_CN + '",icon = "' + ICON_PATH + '", ver = ' + VERSION + ', comp = "' + APP_COMPANY + '", schemeUrl = "' + ACTIVITY.toLowerCase() + '" WHERE appid = ' + APP_ID; db.transaction(function(con1){ con1.executeSql(sql,function(con2,res2){ alert("!") },function(con3,error3){ alert("添加数据出错!") }) }); // updateData(uname, APP_ID,APP_NAME_CN, ICON_PATH, VERSION, APP_COMPANY, ACTIVITY.toLowerCase());//这是原有的函数,被我拉到这个文件中了 } }) });``` **另外** 整个项目是用原生代码写的,不能使用框架和其他引用。

flash AIR连接本地的sqlite,打包发布无效问题

用flash cs写了个air应用,连接了本地的sqlite,ctl+enter测试可以通过,打包部署到本地后,连接数据库无效,求教.

sqlite json中字符串替换

在sqlite中 用sql修改部分字段值 :update AA set aa = replace(aa,'a','b') 但是无法修改是什么原因?该字段值是 一个json串是不是因为该字段值中包双引号

sqlite3提共更改多条记录吗?????????

我只知道更改一条记录是用update 表名 set 字段=? where 字段=? 哪更改多条是怎么样呢,大大们给我说说吧,可老火了 这样写为什么不行update 表名 set id=?,name=?,sex=?,age=? whee id=?, name=?,sex=?,age=?;![图片说明](https://img-ask.csdn.net/upload/201701/11/1484128731_350941.jpg)

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

Intellij IDEA 实用插件安利

1. 前言从2020 年 JVM 生态报告解读 可以看出Intellij IDEA 目前已经稳坐 Java IDE 头把交椅。而且统计得出付费用户已经超过了八成(国外统计)。IDEA 的...

搜狗输入法也在挑战国人的智商!

故事总是一个接着一个到来...上周写完《鲁大师已经彻底沦为一款垃圾流氓软件!》这篇文章之后,鲁大师的市场工作人员就找到了我,希望把这篇文章删除掉。经过一番沟通我先把这篇文章从公号中删除了...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

魂迁光刻,梦绕芯片,中芯国际终获ASML大型光刻机

据羊城晚报报道,近日中芯国际从荷兰进口的一台大型光刻机,顺利通过深圳出口加工区场站两道闸口进入厂区,中芯国际发表公告称该光刻机并非此前盛传的EUV光刻机,主要用于企业复工复产后的生产线扩容。 我们知道EUV主要用于7nm及以下制程的芯片制造,光刻机作为集成电路制造中最关键的设备,对芯片制作工艺有着决定性的影响,被誉为“超精密制造技术皇冠上的明珠”,根据之前中芯国际的公报,目...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

百度工程师,获利10万,判刑3年!

所有一夜暴富的方法都写在刑法中,但总有人心存侥幸。这些年互联网犯罪高发,一些工程师高技术犯罪更是引发关注。这两天,一个百度运维工程师的案例传遍朋友圈。1...

程序员为什么千万不要瞎努力?

本文作者用对比非常鲜明的两个开发团队的故事,讲解了敏捷开发之道 —— 如果你的团队缺乏统一标准的环境,那么即使勤劳努力,不仅会极其耗时而且成果甚微,使用...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《Oracle Java SE编程自学与面试指南》最佳学习路线图2020年最新版(进大厂必备)

正确选择比瞎努力更重要!

字节跳动面试官竟然问了我JDBC?

轻松等回家通知

面试官:你连SSO都不懂,就别来面试了

大厂竟然要考我SSO,卧槽。

实时更新:计算机编程语言排行榜—TIOBE世界编程语言排行榜(2020年6月份最新版)

内容导航: 1、TIOBE排行榜 2、总榜(2020年6月份) 3、本月前三名 3.1、C 3.2、Java 3.3、Python 4、学习路线图 5、参考地址 1、TIOBE排行榜 TIOBE排行榜是根据全世界互联网上有经验的程序员、课程和第三方厂商的数量,并使用搜索引擎(如Google、Bing、Yahoo!)以及Wikipedia、Amazon、YouTube统计出排名数据。

立即提问
相关内容推荐