API call with null database connection Pointer

Hello:


I have read everything I could find on the web but haven't found an answer to my problem.

When I try to send data to my SQLite database I get the following results: Below is also some of the code.


2019-04-24 20:00:11.129795-0400 SQLiteDB[3612:577441] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/wlionelwilliams/Library/Developer/CoreSimulator/Devices/F9116EB7-DC03-4A1D-9147-8D59DD022633/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles

2019-04-24 20:00:11.130255-0400 SQLiteDB[3612:577441] [MC] Reading from private effective user settings.

2019-04-24 20:00:31.831346-0400 SQLiteDB[3612:577441] [logging] API call with invalid database connection pointer

2019-04-24 20:00:31.831465-0400 SQLiteDB[3612:577441] [logging] misuse at line 127715 of [95fbac39ba]

2019-04-24 20:00:31.831607-0400 SQLiteDB[3612:577441] [logging] API call with invalid database connection pointer

2019-04-24 20:00:31.831675-0400 SQLiteDB[3612:577441] [logging] misuse at line 156014 of [95fbac39ba]

bad parameter or other API misuse

Error preparing insert: |(errmsg)

2019-04-24 20:00:31.832078-0400 SQLiteDB[3612:577441] [logging] API called with NULL prepared statement

2019-04-24 20:00:31.832147-0400 SQLiteDB[3612:577441] [logging] misuse at line 87482 of [95fbac39ba]

2019-04-24 20:00:31.832208-0400 SQLiteDB[3612:577441] [logging] API call with invalid database connection pointer

2019-04-24 20:00:31.832266-0400 SQLiteDB[3612:577441] [logging] misuse at line 156014 of [95fbac39ba]

bad parameter or other API misuse

failure binding username |(errmsg)

2019-04-24 20:00:31.832357-0400 SQLiteDB[3612:577441] [logging] API called with NULL prepared statement

2019-04-24 20:00:31.832413-0400 SQLiteDB[3612:577441] [logging] misuse at line 86902 of [95fbac39ba]

2019-04-24 20:00:31.832468-0400 SQLiteDB[3612:577441] [logging] API call with invalid database connection pointer

2019-04-24 20:00:31.832527-0400 SQLiteDB[3612:577441] [logging] misuse at line 156014 of [95fbac39ba]

bad parameter or other API misuse

failure inserting username |(errmsg)

2019-04-24 20:00:31.834585-0400 SQLiteDB[3612:577441] [logging] API called with NULL prepared statement

2019-04-24 20:00:31.834683-0400 SQLiteDB[3612:577441] [logging] misuse at line 87482 of [95fbac39ba]

2019-04-24 20:00:31.834762-0400 SQLiteDB[3612:577441] [logging] API call with invalid database connection pointer

2019-04-24 20:00:31.834826-0400 SQLiteDB[3612:577441] [logging] misuse at line 156014 of [95fbac39ba]

bad parameter or other API misuse

failure binding decision |(errmsg)

2019-04-24 20:00:31.834899-0400 SQLiteDB[3612:577441] [logging] API called with NULL prepared statement

2019-04-24 20:00:31.834956-0400 SQLiteDB[3612:577441] [logging] misuse at line 86902 of [95fbac39ba]

2019-04-24 20:00:31.835012-0400 SQLiteDB[3612:577441] [logging] API call with invalid database connection pointer

2019-04-24 20:00:31.835066-0400 SQLiteDB[3612:577441] [logging] misuse at line 156014 of [95fbac39ba]

bad parameter or other API misuse

failure inserting decision |(errmsg)

2019-04-24 20:00:31.835137-0400 SQLiteDB[3612:577441] [logging] API call with invalid database connection pointer

2019-04-24 20:00:31.835256-0400 SQLiteDB[3612:577441] [logging] misuse at line 156014 of [95fbac39ba]

bad parameter or other API misuse

error finalizing prepared statement |(errmsg)


var stmt: OpaquePointer?

let insertQuery = "INSERT INTO DECISIONS (username,decision) VALUES (?, ?)"

if sqlite3_prepare_v2(db, insertQuery, -1, &stmt, nil ) != SQLITE_OK {

print(String(cString: sqlite3_errmsg(db)))

print("Error preparing insert: |(errmsg)")

}

if sqlite3_bind_text(stmt, 1, username, -1, nil) != SQLITE_OK {

print(String(cString: sqlite3_errmsg(db)))

print("failure binding username |(errmsg)")

}

let insertQuery = "INSERT INTO DECISIONS (username,decision) VALUES (?, ?)"

if sqlite3_prepare_v2(db, insertQuery, -1, &stmt, nil ) != SQLITE_OK {

print(String(cString: sqlite3_errmsg(db)))

print("Error preparing insert: |(errmsg)")

}

if sqlite3_bind_text(stmt, 1, username, -1, nil) != SQLITE_OK {

print(String(cString: sqlite3_errmsg(db)))

print("failure binding username |(errmsg)")

}

if sqlite3_bind_text(stmt, 1, decision, -1, nil) != SQLITE_OK {

print(String(cString: sqlite3_errmsg(db)))

print("failure binding decision |(errmsg)")

}

if sqlite3_step(stmt) != SQLITE_DONE {

print(String(cString: sqlite3_errmsg(db)))

print ("failure inserting decision |(errmsg)")

}

if sqlite3_finalize(stmt) != SQLITE_DONE {

print(String(cString: sqlite3_errmsg(db)))

print ("error finalizing prepared statement |(errmsg)")

}

Answered by wlionel in 358270022

Hello Everyone:


I solved these errors by one simple change that was causing the problem.

the name of the "appendingPathComponent(...) was written as "decisions.db" instead of "decisions":


databasePath = dirPaths[0].appendingPathComponent("decisions").path

Accepted Answer

Hello Everyone:


I solved these errors by one simple change that was causing the problem.

the name of the "appendingPathComponent(...) was written as "decisions.db" instead of "decisions":


databasePath = dirPaths[0].appendingPathComponent("decisions").path

API call with null database connection Pointer
 
 
Q