FMDatabase.executeUpdate errors out when passed string in Swift

72 views
Skip to first unread message

Alex Hall

unread,
Apr 11, 2016, 12:28:50 PM4/11/16
to fm...@googlegroups.com
Hello again list,
This time I'm actually stumped. I'm calling the FMDatabase.executeUpdate(sql:String) function in Swift. When I do, I get an error that this function cannot be invoked with an argument list of type (String). Yet, the docs say that this function, among other forms, can take a string and return a boolean. My line of code is below; the strings in it are all defined before this call, as normal Swift arrays of strings.

let success = db.executeUpdate("insert into users (username, password, email) values ('\(randomUsernames[i])', '\(randomPasswords[i])', '\(randomUsernames[i])@example.com')")


Does anyone know what might be going on? Thanks.

--
Have a great day,
Alex Hall




Mat Gadd

unread,
Apr 11, 2016, 1:24:50 PM4/11/16
to fm...@googlegroups.com
I've not used FMDB with Swift, but I expect it's b cause you're using string interpolation. Try this:

let success = db.executeUpdate("insert into users (username, password, email) values (?, ?, ?)", randomUsernames[i]randomPasswords[i], randomEmails[i])

Sent from my iPhone
Reply all
Reply to author
Forward
0 new messages