Beispiel #1
0
def get_parent_id_for_child(cursor: pyodbc.Cursor, child_account_id: str) -> str:
    """Gets the corresponding parent id for a child's id."""
    try:
        cursor.execute(
            queries.get_child_by_account_id(("ParentGoogleAccountId",)),
            child_account_id,
        )
    except Exception as exc:
        abort(400, str(exc))

    child_res = cursor.fetchone()
    if not child_res:
        abort(404, "Child Account ID not found")

    return child_res.ParentGoogleAccountId
Beispiel #2
0
    def _commitInsert(self, cursor: odbc.Cursor) -> None:
        prop_names = ""
        prop_value_tags = ""
        prop_values = []
        for prop in self.properties:
            if prop.value != None:
                if prop_names != "":
                    prop_names += ","
                    prop_value_tags += ","
                prop_names += prop.name
                prop_value_tags += "?"
                prop_values.append(prop.value)

        cursor.execute(
            "INSERT INTO {0} ({1}) VALUES ({2})".format(
                self._tableName, prop_names, prop_value_tags), prop_values)
        cursor.commit()
        cursor.execute("SELECT LAST_INSERT_ID()")
        self._primaryKey.value = cursor.fetchone()[0]