title: How to insert an array into a SQLite database?
body: <p>I'm trying to insert an array into a SQLite database and I'm having difficulties getting the array variables to insert.  </p>
  
  <p>How can I get variables from the array (username &amp; fullName) to insert in the db?</p>
  
  <p>Here are the error messages:</p>
  
  <pre><code>Property 'username' not found on object of type 'NSString *'
  Property 'fullName' not found on object of type 'NSString *'
  </code></pre>
  
  <p>Here's my code...</p>
  
  <pre><code>if (sqlite3_open([dbPath UTF8String], &amp;database) == SQLITE_OK) {
  
      NSMutableArray *items = result;
  
      sqlite3_stmt *insert_statement;
  
      // prepare the insert statement
      const char*sql = "INSERT INTO people (username, fullName) VALUES(?,?)"; 
      sqlite3_prepare_v2(database, sql, -1, &amp;insert_statement, NULL);
  
      // iterate over an array of dictionaries
      for (NSString *str in items) {
  
          // NSLog(@"%@",str);
  
          // bind variables
          sqlite3_bind_text(insert_statement, 1, [str.username UTF8String], -1, SQLITE_TRANSIENT);
          sqlite3_bind_text(insert_statement, 2, [str.fullName UTF8String], -1, SQLITE_TRANSIENT);
  
          // insert fails
          if (sqlite3_step(insert_statement) != SQLITE_DONE) {
              NSLog(@"Insert failed: %s", sqlite3_errmsg(database));
          }
  
          // reset the statement
          sqlite3_reset(insert_statement);
      }
  
      // release the statement
      sqlite3_finalize(insert_statement);
  }`
  </code></pre>