[3.10] bpo-45581: Raise `MemoryError` in `sqlite3.connect` if SQLite signals memory error (GH-29171) (GH-29323)

(cherry picked from commit e2e62b3808691e15fa44b883270023e42dcad958)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 2cc5f53..6461039 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -113,6 +113,10 @@ pysqlite_connection_init(pysqlite_Connection *self, PyObject *args,
 
     Py_DECREF(database_obj);
 
+    if (self->db == NULL && rc == SQLITE_NOMEM) {
+        PyErr_NoMemory();
+        return -1;
+    }
     if (rc != SQLITE_OK) {
         _pysqlite_seterror(self->db, NULL);
         return -1;